PHP - Why Does This Not Display In An Echo?
Hi,
This text outputs itself when i use it for a form field in an echo " value=\"<? include(\"djmessage.txt\"); ?>\" Why is this? it normally works outside of an echo. Many thanks Similar TutorialsHi there This code below displays the time in different timezones, from a base time of Los Angeles time, and it's working well for us (the time is pulled from the start date field of an event post type within Wordpress). However, if an event is at midday it puts 12:00 pm for the time which can cause confusion internationally as to whether it is midnight or midday. We'd like to display "12:00 noon" instead of "12:00 pm". Does anyone have any idea how this code could be adapted to do this? This code will be used in a Wordpress site so the way the time is displayed is set there. However, Wordpress doesn't have a way to change just this one things that we're looking to do which is to change '12:00 pm' to '12:00 noon'. Thanks! <?php $tas_start_datetime = tribe_get_start_date(); ?><strong>Los Angeles, USA: </strong><?php $date = new DateTime($tas_start_datetime, new DateTimeZone('America/Los_Angeles')); echo $date->format('l, F j\, g:i a') . "\n"; ?><br/><strong>Detroit, USA: </strong><?php $date->setTimezone(new DateTimeZone('America/Detroit')); echo $date->format('l, F j\, g:i a') . "\n"; ?><br/><strong>Accra, Ghana: </strong><?php $date->setTimezone(new DateTimeZone('Africa/Accra')); echo $date->format('l, F j\, g:i a') . "\n"; ?><br/><strong>London, UK: </strong><?php $date->setTimezone(new DateTimeZone('Europe/London')); echo $date->format('l, F j\, g:i a') . "\n"; ?><br/><strong>Lagos, Nigeria: </strong><?php $date->setTimezone(new DateTimeZone('Africa/Lagos')); echo $date->format('l, F j\, g:i a') . "\n"; ?><br/><strong>Auckland, New Zealand: </strong><?php $date->setTimezone(new DateTimeZone('Pacific/Auckland')); echo $date->format('l, F j\, g:i a') . "\n"; ?>
hello, I want to display the echo ''"; in the right place on my website in changepassword_form.html all messages are written in changepassword.php. how can i move these echo after entering the wrong password or username? changepassword.php <?php ........... //success //change password in db $querychange = mysql_query("UPDATE users SET password='$newpassword' WHERE username='$username'"); session_destroy(); echo 'Password Has Been Changed Successfully !'; //move these } else{ echo('new password doesnt match!'); //move these } } else { die('old password doesnt match!'); //move these } } else { echo ""; include 'changepassword_form.html'; exit(); } } else{ echo 'you must be logged '; } ?> move these echos somewhere to my html code how to do these?? Hello, all: I have been having these odd display stuff when I'm either trying to display or call functions or definitions. Seems like they work best when ALWAYS using echo to call them, though they also work without it?? So, what gives? when or how should I use them??? Should Definitions or Functions always be used along with ECHO?? as you can see slightly confused... EXAMPLE: // Why does this line work??? note, see here I'm using echo several times in order to display right) <?php if(RIGHT_COLUMN_WIDTH != '0') { echo "<td valign='top' width='" . RIGHT_COLUMN_WIDTH . "px'>"; echo categories(); echo "</td>";} ?> // But this one doesnt display just right?? Note: see echo not used when categories() function is called, but isnt it still being called by first echo?? <?php if(RIGHT_COLUMN_WIDTH != '0') { echo "<td valign='top' width='" . RIGHT_COLUMN_WIDTH . "px'>" . categories() . "</td>";} ?> Trying to figure out how to make it so name is a link to the profile when its echo anyone know how to do this? im at a huge stand still Code: [Select] <?php $sql = "SELECT name FROM users WHERE DATE_SUB(NOW(),INTERVAL 5 MINUTE) <= lastactive ORDER BY id ASC"; $query = mysql_query($sql) or die(mysql_error()); $count = mysql_num_rows($query); $i = 1; while($row = mysql_fetch_object($query)) { $online_name = htmlspecialchars($row->name); echo '<a href="Inbox.php">"'[$goauld]'</a>"'; ?> The below might be a noob question but, I concatenate two spaces in the below string $new_hebrew_date_string = $hebrewMonthName . ' ' . $hebrewDay . "%"; yet when I execute echo "<br />new_hebrew_date_string is $new_hebrew_date_string<br />"; printf("hebrew_date_string is: %s <br />", $new_hebrew_date_string); Only one space is output in between $hebrewMonthName and $hebrewDay regardless of how many spaces I pad the string with. Strangely enough, the string $new_hebrew_date_string is correctly padded w/spaces when I pass it as a parameter to a mySQL stored procedure. Any ideas anyone? Thank you. hi there, the code below is suppose to display something like the attachement "code2" but instead it displays something like attachement "code1" please assist in find what is wrong with my echo lines.
<?php $counter = 2; $sqlq="select * from state WHERE status = 0 "; $categorysqlq = mysql_query($sqlq); $varq = mysql_num_rows($categorysqlq); while($catfetchq = mysql_fetch_array($categorysqlq)) { $cnty = $catfetchq[0]; $sqllq="select * from vehicle WHERE country = '$cnty' "; $categorysqllq = mysql_query($sqllq); $numsql = "select * from branchaddr WHERE state = '$cnty' "; $numquery = mysql_query($numsql); $varqa = mysql_num_rows($numquery); $cntyfetchq= mysql_fetch_array($numquery); if($varq != 0){ if($counter == 2){ echo "<tr><td><a href=\"transport2.php?id=".$cntyfetchq['state'].">".$catfetchq[1]."(<span style=\"color:red\">".$varqa."</span>)</a></td>"; $counter--; } else{ echo "<td><a href=\"transport2.php?id=".$cntyfetchq['state'].">".$catfetchq[1]."(<span style=\"color:red\">".$varqa."</span>)</a></td></tr>"; $counter = 2; } } } ?>Attached Files code1.png 12.65KB 0 downloads code2.png 25.34KB 0 downloads OK, have no idea what's going on... I've done this a million times... why wont this output!?? I must have a major brain meltdown and dont know it yet!!! Code: [Select] <?php // this echoes just fine: echo $_POST['testfield']; // but this wont echo: echo if (isset($_POST['testfield'])) { $_POST['testfield'] = $test; } echo $test; /// or even this DOESNT echo either!: $_POST['testfield'] = $test; echo $test; ?> How to get this echo line to display as one line? No matter what I have done it displays as two lines. I even tried <nobr></nobr> Teachers Name: John Jones $userid = mysql_real_escape_string($_GET['user_id']); $sql = "select * from users where `id`='$userid' "; $rs = mysql_query($sql); while($row = mysql_fetch_array($rs)) { echo "<h3>Teachers Name: </h3>" . $row["first_name"] . " " . $row["last_name"] ; } Thanks for your help. Hi All, I'm trying to echo the response from an SLA query, the query works and returns the data when I test it on an SQL application.. but when I run it on my webpage it won't echo the result. Please help? <?php $mysqli = mysqli_connect("removed", "removed", "removed", "removed"); $sql = "SELECT posts.message FROM posts INNER JOIN threads ON posts.pid=threads.firstpost WHERE threads.firstpost='1'"; $result = mysqli_query($mysqli, $sql); echo {$result['message']}; ?> So I need to echo a row from my database with php, but where i need to echo is already inside an echo. This is my part of my code: $con = mysql_connect("$host","$username","$password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("main", $con); $result = mysql_query("SELECT * FROM Vendor"); while($row = mysql_fetch_array($result)) { //I need to echo right here .................. but I get a blank page when I try this. Please Help. echo '<option value=$row['vendor_id']>'; echo $row['vendor_id']; echo '</option>'; } mysql_close($con); Result: A Blank page. Thanks in advance! I have a log system that allows 10 logs on each side(Left and right). I am trying to make it so that the left side has the 10 most recent logs, then the right as the next 10. Any ideas? Hi
I try to echo out random lines of a html file and want after submit password to whole content of the same html file. I have two Problems.
1st Problem When I echo out the random lines of the html file I don't get just the text but the code of the html file as well. I don't want that. I just want the text. How to do that?
for($x = 1;$x<=40;$x++) { $lines = file("$filename.html"); echo $lines[rand(0, count($lines)-1)]."<br>"; }I tried instead of "file("$filename.html");" "readfile("$filename.html");" But then I get the random lines plus the whole content. Is there anything else I can use instead of file so that I get the random lines of text without the html code?P.S file_get_contents doesn't work either have tried that one. 2nd Problem: As you could see in my first problem I have a file called $filename.html. After I submit the value of a password I want the whole content. But it is like the program did forget what $filename.html is. How can I make the program remember what $filename.html is? Or with other words how to get the whole content of the html file? My code: if($_POST['submitPasswordIT']){ if ($_POST['passIT']== $password ){ $my_file = file_get_contents("$filename.html"); echo $my_file; } else{ echo "You entered wrong password"; } }If the password isn't correct I get: You entered wrong password. If the password is correct I get nothing. I probably need to create a path to the file "$filename.html", but I don't know exactly how to do that. Hi all I am trying to get the contents from an array using the below SQL query: $sql = mysql_query ("SELECT MAX (postage_world) FROM `basket` "); while ($row = mysql_fetch_array($sql)) { echo $row["id"]; echo $row["description"]; echo $row["postage_world"]; } I need the SQL query to find the highest value from the table and then echo out the results. The error I get is "Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given" Many thanks for your help! For some reason, I can only get 1 row to echo out when there are actually multiple rows in the database that should be echoing. Here is what I have: $result = mysql_query("SELECT * FROM boards WHERE boardname='$board' ORDER BY id LIMIT 10"); $post = mysql_fetch_assoc($result); echo stripslashes($post['message']) . "<br>\n" . " --- ".stripslashes($post['username']). " on ".stripslashes($post['time']) ."\n<hr width=90%>\n"; It pulls the one record great, but it only shows one record... I want to keep it to 10 records, thus the LIMIT in there (which I think I did right...), but it won't even show the ones in there right now (under 10, so that's not an issue yet). Hi freaks, Yes im a noob... I have some data in a db that im echoing out, but the last row wont multiply? The rest works great... I have tried having the data as the following: 1.12 or 0.12 & I have tried having it as a var. Do I need to have a % in there somewhere? Im adding up all the data then I want to multiply by 12% (*$row['markup']) <?php echo $row['Stock1']*$row['qty']+$row['cutting']+$row['production']+$row['additional']+$row['pluscover']+$row['selfcover']*$row['markup'];?> any help would be appreciated. cuzzmunger. What is the correct way to write an if/else statement within an echo? I need to alter this so that I can query to see what data is found and if not correct not to echo the rest of the statement. Code: [Select] echo '<td class="productbox"> <h1>' . $product_title . '</h1> </td>'; So from the above code which is echoed within the single quotes, what is the correct way to include an if else check on a value from the database. I know how its done, but just want to save time and write it the correct way within this. How do I echo the day from the db? It just displays day and I want it to display the day that was set. <select name="date_of_birth" id="date_of_birth"> <option value="">Day</option> <?php $isset = isset($_POST['date_of_birth']); for($day = 1; $day <= 31; ++$day) { echo '<option'; if ($isset && $_POST['date_of_birth'] === $day) { echo ' selected="selected"'; } echo ">${day}</option>\n\t\t\t\t\t\t"; } ?> </select> Hi all, I have a page which simply pulls info from a database by id: <?php include ('connect.php'); $id = $_GET['id']; $query = mysql_query("SELECT * FROM JOBS WHERE id=$id"); if (!$query) { echo "Could not run query: " . mysql_error(); exit; } $row = mysql_fetch_row($query); { echo "<body><h3>" . $row[1]. "</h3>"; echo "<h4>" . $row[2] . "</h4>"; echo "<h4>" . $row[3] . "</h4>"; echo "<h5>Duties & Responsibilities:</h5><ul>"; echo "<li><strong>" . $row[4] . "</strong>" . $row[5] . "</li>"; echo "<li><strong>" . $row[6] . "</strong>" . $row[7] . "</li>"; echo "<li><strong>" . $row[8] . "</strong>" . $row[9] . "</li>"; echo "<li><strong>" . $row[10] . "</strong>" . $row[11] . "</li>"; } ?> However in some cases the rows in the database may only contain data upto row 6 for example, how would I go about coding this so that it only displays rows that exist. If row 6 exists then 7 always will too as the information is connected. I am manually added this stuff into phpmyadmin as I do not need a form as once it is complete then it will not need to be added to. Also row 8 and 9 may contain data but 6 and 7 may not Many Thanks Hi, I can't figure out how to echo <br/> after 14 characters every line from text. Any idea's? Cyto |