|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-02-24 23:03 UTC] tj at primetimesolutions dot com
Description: ------------ It would be helpful and spiffy to have a function or member variable on MySQLi objects that one could use to determine if the connection was a success or failure. According to the documentation, the solution is to call the mysqli_connect_errno() function after construction of the object, but doing so sort of eliminates the "object oriented-ness" of the design, and causes sloppy code (i.e. extra variables required to store status of different connection successes, etc.). PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 02 06:00:01 2025 UTC |
I don't understand. var_dump($no_connected_mysqli_object) gives you. Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'root'@'localhost' (using password: YES) in /home/nixnutz/php/php-src/branches/PHP_5_3_cta/foo.php on line 2 Warning: var_dump(): Property access is not allowed yet in /home/nixnutz/php/php-src/branches/PHP_5_3_cta/foo.php on line 3 Warning: var_dump(): Property access is not allowed yet in /home/nixnutz/php/php-src/branches/PHP_5_3_cta/foo.php on line 3 Warning: var_dump(): Couldn't fetch mysqli in /home/nixnutz/php/php-src/branches/PHP_5_3_cta/foo.php on line 3 Warning: var_dump(): Couldn't fetch mysqli in /home/nixnutz/php/php-src/branches/PHP_5_3_cta/foo.php on line 3 Warning: var_dump(): Couldn't fetch mysqli in /home/nixnutz/php/php-src/branches/PHP_5_3_cta/foo.php on line 3 Warning: var_dump(): Couldn't fetch mysqli in /home/nixnutz/php/php-src/branches/PHP_5_3_cta/foo.php on line 3 Warning: var_dump(): Couldn't fetch mysqli in /home/nixnutz/php/php-src/branches/PHP_5_3_cta/foo.php on line 3 Warning: var_dump(): Couldn't fetch mysqli in /home/nixnutz/php/php-src/branches/PHP_5_3_cta/foo.php on line 3 Warning: var_dump(): Couldn't fetch mysqli in /home/nixnutz/php/php-src/branches/PHP_5_3_cta/foo.php on line 3 Warning: var_dump(): Couldn't fetch mysqli in /home/nixnutz/php/php-src/branches/PHP_5_3_cta/foo.php on line 3 Warning: var_dump(): Couldn't fetch mysqli in /home/nixnutz/php/php-src/branches/PHP_5_3_cta/foo.php on line 3 Warning: var_dump(): Couldn't fetch mysqli in /home/nixnutz/php/php-src/branches/PHP_5_3_cta/foo.php on line 3 Warning: var_dump(): Couldn't fetch mysqli in /home/nixnutz/php/php-src/branches/PHP_5_3_cta/foo.php on line 3 Warning: var_dump(): Couldn't fetch mysqli in /home/nixnutz/php/php-src/branches/PHP_5_3_cta/foo.php on line 3 object(mysqli)#1 (17) { ["affected_rows"]=> NULL ["client_info"]=> NULL ["client_version"]=> int(50007) ["connect_errno"]=> int(1045) ["connect_error"]=> string(63) "Access denied for user 'root'@'localhost' (using password: YES)" ["errno"]=> NULL ["error"]=> NULL ["field_count"]=> NULL ["host_info"]=> NULL ["info"]=> NULL ["insert_id"]=> NULL ["server_info"]=> NULL ["server_version"]=> NULL ["sqlstate"]=> NULL ["protocol_version"]=> NULL ["thread_id"]=> NULL ["warning_count"]=> NULL } And: $m = @new mysqli("localhost", "root", "rooti"); var_dump(@$m->connect_error); ixnutz@linux-fuxh:~/php/php-src/branches/PHP_5_3_cta> sapi/cli/php foo.php Warning: mysqli::mysqli(): (28000/1045): Access denied for user 'root'@'localhost' (using password: YES) in /home/nixnutz/php/php-src/branches/PHP_5_3_cta/foo.php on line 2 string(63) "Access denied for user 'root'@'localhost' (using password: YES)" There's your propery. If you suppress warnings you can even access it.