note 89141 modified in mysqli.connect-error by danbrown
| From: | danbrown@php.net | Date: | Tue, 24 Feb 2009 04:00:10 +0000 |
| Subject: | note 89141 modified in mysqli.connect-error by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-151044@lists.php.net to get a copy of this message | ||
The object oriented style does not work for connect_error and connect_errno. However, the procedural
style (mysqli_connect_error and mysql_connect_errno) works perfectly and can be mixed in with object
oriented style code.
<?php
$mysqli = new mysqli('localhost', 'user', 'pass', 'db');
if(mysqli_connect_errno())
{
die('MySQL connection error: ' . mysqli_connect_error());
}
?>
mysqli_connect_errno() returns zero on successful connections, an error number otherwise.
--was--
The object oriented style does not work for connect_error and connect_errno. However, the procedural
style (mysqli_connect_error and mysql_connect_errno) works perfectly and can be mixed in with object
oriented style code.
$mysqli = new mysqli('localhost', 'user', 'pass', 'db');
if(mysqli_connect_errno())
{
die('MySQL connection error: ' . mysqli_connect_error());
}
mysqli_connect_errno() returns zero on successful connections, an error number otherwise.
http://php.net/manual/en/mysqli.connect-error.php