Richard Lynch wrote:
I found out that new mysqli doesn't throw an exception during it's construction. The way I figured out how to deal with it was to do this:On Fri, January 5, 2007 4:35 pm, Jochem Maas wrote:Richard Lynch wrote:On Fri, January 5, 2007 12:29 pm, Richard Morris wrote:I am having this problem that I hope can be worked around. I make a connection to our MySQL database using the object version of mysqli. If access is denied because of an incorrect username or password, mysqli displays an error. Is there any way to suppress the error message?To suppress a single error message in a single line you can use the @ operator in PHP: @this_code_errors_but_youll_never_see_the_error(...); To catch errors in a more general manner: http://php.net/set_error_handler Also, since mysqli is new-fangled, it's probably using that fancy try/catch/throw stuff, so you could PROBABLY wrap it in a try/catchif that was the case his error would have mentioned something about an uncaught exception.With all the __toString and SPL array/object mumbo-jumbo going on, I never know what's going on anymore with these things... $db =@ new mysqli('localhost', 'user', 'badpass', 'test'); With this in place no warning messages are displayed and then I can follow it up with a check for any errors using mysqli_connect_errno(). I was a little surprised to see it not use an exception as I thought that would be a better mechanism to know something is wrong when dealing with objects. Either way, it was a simple fix. I just want to thank Fernando Chure for pointing me in the right direction. --
|