Re: [PHP] Apache - MySQL connection via PHP

2004-12-10 Thread Richard Lynch
Mike Francis wrote:
> 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.

>// Connect to the database server
>  $dbcnx = @mysql_connect('localhost', 'root', 'thisismypassword');
>  if (!$dbcnx) {
>  exit('Unable to connect to the ' .
>  'database server at this time.');


I believe http://mysql_error could be used in your code right before the
first 'exit' to give you more information.

Also try taking out the '@' for a trial run, just to see if you get a
useful error message from that.

You can put '@' back in after you fix this problem -- but it would be even
better to add an http://php.net/error_log before that exit with
http://php.net/mysql_error so that you can log your errors to the Apache
error log.

Then, when you have problems, you have to remember to open up your Apache
error log file.

In a standard install, that's:
C:\Program Files\Apache Group\apache2\logs\error_log
I do believe.

PS Excellent post, particularly the efforts to insure that MySQL was
running/working!

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Apache - MySQL connection via PHP

2004-12-10 Thread Mike Francis
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:
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
http://www.w3.org/1999/xhtml";>


Our List of Jokes




 Unable to connect to the ' .
 'database server at this time.');
 }
 // Select the jokes database
 if ([EMAIL PROTECTED]('ijdb')) {
 exit('Unable to locate the joke ' .
 'database at this time.');
 }
 ?>
Here are all the jokes in our database:

 Error performing query: ' . mysql_error() . '');
 }
 // Display the text of each joke in a paragraph
 while ($row = mysql_fetch_array($result)) {
 echo '' . $row['joketext'] . '';
 }
 ?>