#25138 [Opn->Bgs]: mysql_connect example
| From: | didou@php.net | Date: | Tue, 19 Aug 2003 12:01:04 +0000 |
| Subject: | #25138 [Opn->Bgs]: mysql_connect example | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969355927@lists.php.net to get a copy of this message | ||
ID: 25138
Updated by: didou@php.net
Reported By: curt at zirzow dot dyndns dot org
-Status: Open
+Status: Bogus
Bug Type: Documentation problem
PHP Version: Irrelevant
New Comment:
Actually it works.
didou@tunis:/$ php -v
4.2.3
didou@tunis:/$ php
<?php
error_reporting(0);
mysql_connect('localhost','root','foo') or die("I'm dead ::
" .
mysql_error() . "\n");
?>
output :
I'm dead :: Access denied for user: 'root@localhost' (Using password:
YES)
Previous Comments:
------------------------------------------------------------------------
[2003-08-18 21:26:52] curt at zirzow dot dyndns dot org
Description:
------------
mysql_connect: example 1:
<?php
$link = mysql_connect("localhost", "mysql_user", "mysql_password")
or die("Could not connect: " . mysql_error());
print ("Connected successfully");
mysql_close($link);
?>
mysql_error() will not give a reason why the connect failed, according
to:
http://bugs.php.net/bug.php?id=24689
php4 will never give that message but php5 will. I havn't tested to see
if this is true for php5.
An alternative is to use $php_errormsg, but that can only used if
php_ini.track_errors is set.
Related Issues:
Reason this occurs [closed]
mysql_error() documentation [closed]
http://bugs.php.net/bug.php?id=20743
Thanks,
Curt
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25138&edit=1