Forum Moderators: coopster
HTML><HEAD><TITLE> Our List of Jokes </TITLE><HEAD><BODY><?php
// Connect to the database server $dbcnx = @mysql_connect("localhost", "********", "**"); if (!$dbcnx) { echo( "<P>Unable to connect to the " . "database server at this time.</P>" ); exit(); }
// Select the jokes database if (! @mysql_select_db("*********") ) { echo( "<P>Unable to locate the joke " . "database at this time.</P>" ); exit(); }
?><P> Here are all the jokes in our database: </P><BLOCKQUOTE>
<?php // Request the text of all the jokes $result = mysql_query( "SELECT email FROM users"); if (!$result) { echo("<P>Error performing query: " . mysql_error() . "</P>"); exit(); }
// Display the text of each joke in a paragraph while ( $row = mysql_fetch_array($result) ) { echo("<P>" . $row["email"] . "</P>"); }
?>
</BLOCKQUOTE></BODY></HTML>
Did you enter your script verbatim? I ask because you appear to have most of your php code commented.
// Display the text of each joke in a paragraph while ( $row = mysql_fetch_array($result) ) { echo("<P>" . $row["email"] . "</P>"); }
Should be:
// Display the text of each joke in a paragraph
while ( $row = mysql_fetch_array($result) ) { echo("<P>" . $row["email"] . "</P>"); }
The double slash, //, is used to create a comment in your code. Anything directly following it on the same line will not be executed. Also, this line in your script will reveal errors if they exist.
error_reporting(E_ALL);
() usually surround function arguments or parameters. They can also group certain arguments together, just like you probably learned in your old math classes:
1 + 3 * ( 1 + 1) = 8
[] are usually surrounding an index for an array value. The PHP Manual can teach you more about Arrays [php.net] than I can here though.