|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #25138 mysql_connect example
Submitted: 2003-08-18 21:26 UTC Modified: 2003-08-19 07:01 UTC
From: curt at zirzow dot dyndns dot org Assigned:
Status: Not a bug Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: curt at zirzow dot dyndns dot org
New email:
PHP Version: OS:


 [2003-08-18 21:26 UTC] curt at zirzow dot dyndns dot org
mysql_connect: example 1:
    $link = mysql_connect("localhost", "mysql_user", "mysql_password")
        or die("Could not connect: " . mysql_error());
    print ("Connected successfully");

mysql_error() will not give a reason why the connect failed, according to:

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]



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-19 07:01 UTC]
Actually it works.

didou@tunis:/$ php -v
didou@tunis:/$ php


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)

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Oct 18 20:03:33 2021 UTC