Check mysql database connection
I'm running an installation script but before I create any tables I check to make sure the user can connect to their MySQL database. Below is the code I'm using which displays my error message if the user can not connect to their MySQL database but it also shows the "php" error mesage.
"Warning: mysql_connect(): Access denied for user: 'root2@localhost' (Using password: YES) in C:\Apache Group\Apache2\htdocs\poll\installation.php on line 81
"
How can I get rid of the "php" error message so only mine is displayed?
PHP Code:
$db=mysql_connect($_POST['host'], $_POST['username'], $_POST['password']) // connecting to the database
or
die("Couldn't connect to MySQL");
If I had @ in front of my mysql_connect it works!! :)
Re: Check mysql database connection
Put an AT (@) symbol before the function call.
Code:
@mysql_pconnect(user,pass,host) or die("Could not establish a connection!");
whoops, I didn't notice you solved your own problem..