Forum Moderators: coopster

Message Too Old, No Replies

Not Displaying any errors

         

paul161

6:09 am on Jun 16, 2005 (gmt 0)

10+ Year Member



I have this script which is not working its not even displaying any errors even when I enter the wrong passwords and user names in my connection string.
Why is this?

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>

grandpa

6:22 am on Jun 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



HI paul161. Welcome to WebmasterWorld

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);

anshul

6:49 am on Jun 16, 2005 (gmt 0)

10+ Year Member



Also, check this in php.ini
display_errors = On

coopster

12:46 pm on Jun 16, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



... but don't leave that on in a live installation. Show errors during testing, but not in your LIVE environment.

paul161

5:12 pm on Jun 16, 2005 (gmt 0)

10+ Year Member



Thanks for your reply I'm new to Programming Do you know of any good web sites that explain what all the php sysbols mean the ones like this () [ ]
Thank
My script is working know.
Thanks

coopster

5:55 pm on Jun 16, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



No, can't say I do. But I'll try to explain to you what they mean in PHP --

() 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.