At 11:48 PM -0500 10/6/99, Martin Ramsch wrote:
>On Tue, 1999-10-05 14:17:05 -0600, Shawn Blazier wrote:
>> My problem is that I can't connect to MySQL via a PHP script.
>> I tried:
>> mysql_connect("localhost", "username", "password")
>> Is there a way to debug this?
>In many cases it helps to watch the error codes!
> $cid = mysql_connect("localhost", "username", "password")
> or die("Can't connect : error ".mysql_errno().": ".mysql_error());
> // ...
Actually, this won't work. mysql_errno() and mysql_error() don't
return anything until you have a successful connection, and
thus can't be used to report reasons for connection failure.
In this way they are different than their C API counterparts.
You have to enable track_errors and then you can reference $php_errormsg.
Paul DuBois, paul@stripped