PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

mysqli::__construct> <mysqli->connect_errno
Last updated: Fri, 22 Aug 2008

view this page in

mysqli->connect_error

mysqli_connect_error

(PHP 5)

mysqli->connect_error -- mysqli_connect_errorReturns 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());
}
?>



add a note add a note User Contributed Notes
mysqli->connect_error
bero at arklinux dot org dot SPAM dot TO dot microsoft dot com
10-May-2004 12:04
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::__construct> <mysqli->connect_errno
Last updated: Fri, 22 Aug 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites