handling failure to connect

Security issues related to php and mysql usage. How to make your code secure? Security measures and configurations? It's all in here!

Moderators: egami, macek, gesf

Post Reply
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 824
Joined: Sun Jun 02, 2002 3:09 am

Wed Dec 29, 2004 1:00 pm

only one reason - you dont have such user with this passsword.
-----------
try to use root with empty password at localhost.

User avatar
Redcircle
Moderator
Moderator
Posts: 826
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Sun Jan 02, 2005 5:22 am

oleg his problem is that his mysql server is down and it's still trying to authenticate.. this has happened to me.. but in my case it was becasue of a bad sql statement(wierd I know).

a way around it would be to create custom sql error handling.

User avatar
Alexej Kubarev
Site Admin
Site Admin
Posts: 2213
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län
Contact:

Sun Jan 02, 2005 7:13 am

Redcircle... im not really sure that its the way you are saying...

I had several problems like that when i misstyped the username or password... If the server is down it would give you an error message: Could not connect to the server for 30 seconds or something like that

Custom erros handling:

@mysql_query($sql) or die("Im sorry!, but the script has encountered a problem, Error code: ".mysql_errno());

Note that you will have to suppress errors so it will not show warnings
However the last part with die() is optional... you can youse some cutom command that will, for instance write everything to an error-log or something,,, it can send emails to you and so on... or you can simply ignore it and dont do anything..

Note thar the user must have access from the localhost OR remote hosts (depending on where your server is) so it can connect..
Best Regards,
Alexej Kubarev
-------------------------------
Zend Certified Engineer
Image Image

Post Reply