Re: [PHP] Re: Sorry forgot to include the code for my last message - Mike Francis
Hi David, Thanks for your help. I've taken out the @ character, and added the error-trapping code to my file. The results: When I run the file, nothing untoward is reported, and I end up with a blank screen in IE / Moxilla Firebird / Opera. There are no errors reported. In the Apache error log, there are no error or movement messages reported for this operation. In the Apache Access Log the following is reported: 127.0.0.1 - - [12/Dec/2004:13:23:19 +] GET / HTTP/1.1 200 1494 127.0.0.1 - - [12/Dec/2004:13:23:20 +] GET /apache_pb.gif HTTP/1.1 304 - 127.0.0.1 - - [12/Dec/2004:13:23:32 +] GET /mysqlconnectcomplete.php HTTP/1.1 200 - I have the usual permissions on the database server which is accessible via the command prompt with no problem. I have the MyODBC driver installed and configured just in case PHP is looking for it for some strange reason. I've pasted the code below this message: Used Code:- !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; html xmlns=http://www.w3.org/1999/xhtml; head titleOur List of Jokes/title meta http-equiv=content-type content=text/html; charset=iso-8859-1 / /head body ?php // Connect to the database server $dbcnx = mysql_connect('localhost', 'root', 'MyPassWord'); if (!$dbcnx) { echo 'pUnable to connect to the ' . 'database server at this time./p' ); echo mysql_error(); exit(); } // Select the jokes database if ([EMAIL PROTECTED]('ijdb')) { echo mysql_error(); exit('pUnable to locate the joke ' . 'database at this time./p'); } ? pHere are all the jokes in our database:/p blockquote ?php // Request the text of all the jokes $result = mysql_query('SELECT joketext FROM joke'); if (!$result) { exit('pError performing query: ' . mysql_error() . '/p'); } // Display the text of each joke in a paragraph while ($row = mysql_fetch_array($result)) { echo 'p' . $row['joketext'] . '/p'; } ? /blockquote /body /html - Original Message - From: David Robley [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Sunday, December 12, 2004 5:25 AM Subject: [PHP] Re: Sorry forgot to include the code for my last message - Mike Francis On Sun, 12 Dec 2004 07:03, Mike Francis wrote: !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; html xmlns=http://www.w3.org/1999/xhtml; head titleOur List of Jokes/title meta http-equiv=content-type content=text/html; charset=iso-8859-1 / /head body ?php // Connect to the database server $dbcnx = @mysql_connect('localhost', 'root', 'MyPassword'); if (!$dbcnx) { echo 'pUnable to connect to the ' . 'database server at this time./p' ); Note that using the @ in front of the connect suppresses any error messsages that may be returned from the connect; I would get rid of that. Then add here: echo mysql_error(); exit(); } // Select the jokes database if ([EMAIL PROTECTED]('ijdb')) { And use mysql_error() here too. exit('pUnable to locate the joke ' . 'database at this time./p'); } ? mysql_error() will return a useful error message. -- David Robley Backups? We doan *NEED* no steenking baX%^~,VbKx NO CARRIER -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Sorry forgot to include the code for my last message - Mike Francis
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; html xmlns=http://www.w3.org/1999/xhtml; head titleOur List of Jokes/title meta http-equiv=content-type content=text/html; charset=iso-8859-1 / /head body ?php // Connect to the database server $dbcnx = @mysql_connect('localhost', 'root', 'MyPassword'); if (!$dbcnx) { echo 'pUnable to connect to the ' . 'database server at this time./p' ); exit(); } // Select the jokes database if ([EMAIL PROTECTED]('ijdb')) { exit('pUnable to locate the joke ' . 'database at this time./p'); } ? pHere are all the jokes in our database:/p blockquote ?php // Request the text of all the jokes $result = @mysql_query('SELECT joketext FROM joke'); if (!$result) { exit('pError performing query: ' . mysql_error() . '/p'); } // Display the text of each joke in a paragraph while ($row = mysql_fetch_array($result)) { echo 'p' . $row['joketext'] . '/p'; } ? /blockquote /body /html
[PHP] MySQL Connection problem
Hi, I have Apache 2, PHP 5 and MySQL 4.1 installed on an XP pro box. I have created a new database 'ijdb' with a single table 'joke' and have entered data into two of the three fields in the table. I can access the database / tables / data from a command prompt. However, when I try to connect through WAMP I either receive a 'Unable to connect to the database server at this time.' error message - which is my default error message, or, I receive a blank window in IE / Mozilla / Opera etc and no error messages. I have tried removing the @ from the file and this has no effect - interesting?! The error logs do not reveal anything that indicates a missing table / field. I wonder if anyone has any ideas ? Cheers, Mike
[PHP] Apache - MySQL connection via PHP
Hi, I am having a problem connecting to a MySQL database via PHP. I have Apache 2.0.52, PHP 5.0.2 and MySQL 4.1 installed and working OK individually. I have copied phpmysql.dll and mysqli.dll at different times to Windows/System32. I have set up a successful MyODBC connection with the database - so it exists. I can access MySQL from the command prompt, and from a web interface with no problem. However, when I run the following code I get a Unable to connect to the database server at this time. error message. If some kind soul could point me in the right direction I would be very grateful!! This is the code: !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd; html xmlns=http://www.w3.org/1999/xhtml; head titleOur List of Jokes/title meta http-equiv=content-type content=text/html; charset=iso-8859-1 / /head body ?php // Connect to the database server $dbcnx = @mysql_connect('localhost', 'root', 'thisismypassword'); if (!$dbcnx) { exit('pUnable to connect to the ' . 'database server at this time./p'); } // Select the jokes database if ([EMAIL PROTECTED]('ijdb')) { exit('pUnable to locate the joke ' . 'database at this time./p'); } ? pHere are all the jokes in our database:/p blockquote ?php // Request the text of all the jokes $result = @mysql_query('SELECT joketext FROM joke'); if (!$result) { exit('pError performing query: ' . mysql_error() . '/p'); } // Display the text of each joke in a paragraph while ($row = mysql_fetch_array($result)) { echo 'p' . $row['joketext'] . '/p'; } ? /blockquote /body /html