I have an issue with mysql_connect()
. I have done complex research, but found only some general articles about PHP error control operator or custom error handling in PHP and similar ones. My issue is like below:
I have this code and supposing to suppress mysql_connect()
's warning when the connection fails. When I was writing it, my thoughts were like this:
"Turn off errors, then connect to mysql server and if connection fails, suppress warning, then select the database and if selecting fails, suppress warning, and finally turn on errors."
But when I kill the MySQL service process, from PHP I get this warning:
Warning: mysql_connect(): in C:\fakepath\connect.php on line 29
Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in C:\fakepath\connect.php on line 31
And that's not what the script I have supposed to do. Could you someone please explain me why does PHP do this?
I am aware that PHP's mysql extension is not recommended; but what I am working on is an older project and I know what I do.