05-07-2008, 10:37 AM
|
#3 (permalink)
|
|
The Prestige
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
|
Testing it just now, contrary to the manual the __construct method doesn't seem to return false on connect failure; it instead returns an object of type mysqli along with the warning
Code:
Warning: mysqli::mysqli() [function.mysqli-mysqli]: (28000/1045): Access denied for user 'user'@'localhost' (using password: YES)
therefore use mysqli_connect_errno()
PHP Code:
$mysqli = new mysqli('localhost', 'user', 'password', 'db');
if (mysqli_connect_errno()) { die('Connect failed: ' . mysqli_connect_error()); }
and xenon is correct error suppression can have a speed impact on your script, so use error_reporting(0); to hide all warnings/errors/notices etc etc and use your own error handling stuff (for example exceptions)
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
|
|
|
|