PDA

Click to See Complete Forum and Search --> : Check mysql database connection


lintz
Jan 14th, 2005, 03:38 PM
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?

$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!! :)

kows
Jan 21st, 2005, 10:36 AM
Put an AT (@) symbol before the function call.

@mysql_pconnect(user,pass,host) or die("Could not establish a connection!");

whoops, I didn't notice you solved your own problem..