The reason for mysqli_connect_error() not being available as $link->connect_error [looks like an inconsistency superficially] is that at the time mysqli_connect_error() matters (when something goes wrong), $link is null, and therefore not a mysqli object ---> you'd be accessing NULL->connect_error, which can't make any sense.
mysqli->connect_error
mysqli_connect_error
(PHP 5)
mysqli->connect_error -- mysqli_connect_error — Returns a string description of the last connect error
Description
mysqli
string $connect_error;
string mysqli_connect_error
( void
)
Returns the last error message string from the last call to mysqli_connect().
Return Values
A string that describes the error. An empty string if no error occurred.
Examples
Example #1 mysqli_connect_error() example
<?php
$link = @mysqli_connect("localhost", "nonexisting_user", "");
if (!$link) {
printf("Can't connect to localhost. Error: %s\n", mysqli_connect_error());
}
?>
mysqli->connect_error
bero at arklinux dot org dot SPAM dot TO dot microsoft dot com
10-May-2004 12:04
10-May-2004 12:04
