PHP - Print Or Echo?
Should i be using print() or echo() for an xmlhttp.responsetext ?
Code: [Select] <?php //================================================================ // Configure connection parameters $connect_string="DRIVER={Sybase SQL Anywhere 5.0}; SERVER=ACMSQL036A; DATABASE=BACKOFF"; $dbuser="DBA" $dbpswd="SQL" //================================================================ // Connect to DB $conn = odbc_connect($connect_string, $dbuser, $dbpswd); // Query $xrefnum = $_GET['ae_xrefnum']; $qry = "SELECT xrefnum, plunum FROM DBA.PLU_Cross_Ref where xrefnum = '$xrefnum'"; // Get Result $result = odbc_exec($conn,$qry); if (!$result) { echo odbc_errormsg($conn); } // Get Data From Result $row=odbc_fetch_array($result); // Show data print($row[plunum]); } // Free Result odbc_free_result($result); // Close Connection odbc_close($conn); //================================================================ ?> Similar TutorialsHi, I am trying to get the form field to echo a php variable. The problem is that the form is 'Printed' via php. print "<td width=\"300\" valign=\"top\"><input type=\"text\" name=\"usr\" value=\"i.e. JBloggs \" onfocus=\"if(!this._haschanged){this.value=''};this._haschanged=true;\" tabindex=\"1\"></td>"; Instead of the value being i.e. JBloggs have it echo the $name variable. Any input would be appreciated. i have proof, hold on.
In PHP there are two basic ways to get output: echo and print.
meant there was more ways but they werent basic.
Edited by socialemo, 22 January 2015 - 01:33 AM. Hello guys, I want put one form into echo or print, but in the same time i want use $arrays on form. Take a look here <?php print "<form action="https://www.moneybookers.com/app/payment.pl" method="post" target="_blank"> <input type="hidden" name="pay_to_email" value="me@me.com"> <input type="hidden" name="status_url" value="$mail"> <input type="hidden" name="language" value="GR"> <input type="hidden" name="amount" value="$price"> <input type="hidden" name="currency" value="EUR"> <input type="hidden" name="detail1_description" value="$pack"> <input type="hidden" name="detail1_text" value="$review"> <input type="submit" value="Pay!"> </form>"; ?> but all this make an error. from what i can understand, i cant put second "" ine print Can u help me? Hi! I wonder why this code is working: for($i=0; $i<5; print $i++); while this code: for($i=0; $i<5; echo $i++); gives the error PHP Parse error: syntax error, unexpected T_ECHO, expecting ')' After spending some hours at php.net I learned that both calls ('echo' and 'print') are not real functions, but I wonder why they behave so different in the same context?! Also 'tricks' like for($i=0; $i<5; (echo $i), $i++); do not work. Is 'echo' just forbidden in that particular case? Best regards! I set up a form that you can type html code into. When you click submit it sends the form data to a php script that receives the data and then prints it. Basically im trying to accomplish something similar to this http://www.w3schools.com/html/tryit.asp?filename=tryhtml_intro. I have tried to print the html code using echo and print_r. The problem is that it is not displaying correctly. For instance if i were to type in Code: [Select] <body bgcolor="FFCC00"> Nothing would happen. Most of the html displays correctly. What is the reason behind this? Do i need to use a different command to print the form variable? Or do i need to save it as an html document then display it? Hey guys...I have a php that loads when the user is being taken after making a purchase. On that php file, echo and print are disabled...and I need to send a variable from that php file to flash, doesnt matter is flash, could be other php file, html, anyway... <param name="movie" value="retorno.swf?userId=<?php echo $Referencia; ?>" /> On the example above I am using echo $Referencia...I need some function to substitue echo/print... Any ideas??? Thanks in advance! 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; ?> 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. Hello, How to customize print page in php ? I had a page, but I need to print it like an invoice look page. Thanks in advance Hello.
i am totally new to php and just started to learn now. i just dont understand why the following code is not printing the username that i enter on the page.
Please note that the code itself is saved with the name "basicForm.php".
Thanks.
<html> Code: [Select] $query ="SELECT oneID FROM table WHERE table.PersonID = 'game.PlayerA'" ; $result = mysql_query($query); $row = mysql_fetch_array($result); $oneID = $row[0]; [code] If I then echo "$oneID" why does it not print anything? $result echos resource7 I'm working on a site where I've implemented a simple back end wysiwyg editor for content on a page. Then on the public page I run a php query to pull that content and display it. But doing this cancels out the css I have been using to split content into two columns. Is there a way to do this in php, or is there a way to circumvent the problem? ( also tried echoing the entire css style along with the query result - that didn't work either) The <p id='container_sub'> is what is split into two columns. I tried it outside of the query, and inside the query around where I echo results. Neither worked. Here's the basic php code, and further down the css that makes two columns: Code: [Select] <?php $pageid = '2'; // Formulate Query // This is the best way to perform an SQL query // For more examples, see mysql_real_escape_string() $query = sprintf("SELECT content FROM tbl_pages WHERE page_id='%s'", mysql_real_escape_string($pageid)); // Perform Query $result = mysql_query($query); // Check result // This shows the actual query sent to MySQL, and the error. Useful for debugging. if (!$result) { $message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; die($message); } // Use result // Attempting to print $result won't allow access to information in the resource // One of the mysql result functions must be used // See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc. while ($row = mysql_fetch_assoc($result)) { echo "<p id='container_sub'>".$row['content']."</p>"; } // Free the resources associated with the result set // This is done automatically at the end of the script mysql_free_result($result); ?> The css.... Code: [Select] #container_sub {-moz-column-count: 2; -moz-column-gap: 25px; -webkit-column-count: 2; -webkit-column-gap: 20px; column-count: 2; column-gap: 20px;} #container_sub2 {-moz-column-count: 2; -moz-column-gap: 25px; -webkit-column-count: 2; -webkit-column-gap: 20px; column-count: 2; column-gap: 20px;} Hi I have this code to echo th econtents of a table, which contains 100 rows. I want to be able to display all 100 rows. The problem is that it displays 99 (it excludes the first). I've tried to backtrack to reconstruct the code to find out where the error is but no joy. Any ideas? Thanks in advance! Code: [Select] .... // get all entries from table $sql = "SELECT * FROM 100words ORDER BY word_id"; $result = mysqli_query($dbc, $sql); $r = mysqli_fetch_row($result); //print table entries to screen in columns echo '<div id="container">'; // results presented in html table 5 columns, 20 rows per page echo '<div id="outerbox">'; echo '<div class="innerbox">'; echo '<table class="centerresults" border="0">' . "\n"; echo '<td>'; $i = 0; $max_columns = 5; while ($list = mysqli_fetch_assoc($result)) { extract($list); // open row if counter is zero if($i == 0) echo '<tr>' . "\n"; echo '<td width="150px"><a href="word.php?w=' . $list['word'] . '">' . $list['word'] . "</a></td> \n "; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo '</td>' . "\n"; $i=0; } // END if(++$i == $max_columns) { } // END while (!empty($myArray)) { //} END while ($list = mysql_fetch_array($result)) { //END if($i < $max_columns) { echo '</tr>' . "\n"; echo '</table>' . "\n"; echo '</div>'; echo '</div>'; This topic has been moved to Installation in Windows. http://www.phpfreaks.com/forums/index.php?topic=351150.0 Hello guys and gals, I am pretty green to PHP! I have an empty array that that I am trying to put images into. The thing is I have a certain file name in the folder, I want to exclude that file. This is what I have tried, any advice would be appreciated! Code: [Select] $thumbImg[] = array(); foreach (glob($DImg) as $PImg) { if (!is_file("thumbnail.jpg")) { $thumbImg[] = "<img src=\"pathtoimage\">"; } } Later on the page I am printing it out with this. It is still including the thumbnail.jpg image. Thank you in advance!! Code: [Select] for ($i=0; $i<count($thumbImg); $i++) print $thumbImg[$i]; Hi, What is the best way to print the local date and time, my website have customers from 4 or 5 countries. Saudi - UTC+3 Dubai - UTC+4 India - UTC+5.30 how to print the local time for them Thanks, I have the following code but I cannot get it to print the results of the array into my web page. Help would be so appreciated!! Code: [Select] $sql = "SELECT RegName, SireID, DamID FROM pedigrees WHERE ID="; $DoggieIDQ = $sql . $values["ID"]; $DoggieIDR = db_query($DoggieIDQ,$conn); $DoggieID = $_GET['ID']; $Depth = 1; $DepthLimit=8; function getParents($DoggieID, $Depth, $DepthLimit) { $Sire = getSire($DoggieID); $Dam = getDAM($DoggieID); $Depth++; if ($Depth == $DepthLimit) { return array($Sire, $Dam); } else { # Now get grandparents too $SireParents = getParents($Sire, $Depth, $DepthLimit); $DamParents = getParents($Dam, $Depth, $DepthLimit); return array($Sire, $Dam, $SireParents, $DamParents); } } |