List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:October 7 1999 11:43am
Subject:Re: PHP to MySQL
View as plain text  
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!
>
><?php
>   $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
Thread
PHP to MySQLShawn Blazier5 Oct
  • Re: PHP to MySQLJunster5 Oct
    • DBI:mysql Can't connect to local MySQL serverGregory McCann6 Oct
      • Re: DBI:mysql Can't connect to local MySQL serverThimble Smith6 Oct
        • Re: DBI:mysql Can't connect to local MySQL serverGregory McCann6 Oct
          • Re: DBI:mysql Can't connect to local MySQL serverThimble Smith6 Oct
  • Re: PHP to MySQLMartin Ramsch7 Oct
    • Re: PHP to MySQLPaul DuBois7 Oct