Re: Apache - MySQL connection via PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

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


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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux