db connection issue

A

Anonymous

Guest
lol... it seems that your @ sign before calling mysql_connect ignores any error that occured, AFAIK @ symbol is used to bypass any error on script/code so users won't see original error message (i've found it on some PHP security from O'Reily)

try remove the @ so your code will be :

Code:
$username = "*******"; 
$password = "*******"; 
$hostname = "localhost"; 

//connection to the database 
echo "test"; 

$connection = mysql_connect($hostname, $username, $password) 
or die ("Could not connect to the database server 
at this time. Please try later."); 

echo "Database Connected!";
 
here's what i do for a connection script...

Code:
$theuser = "******";
$thehost = "localhost";
$thepassword = "*****";
$thedatabase = "*******";

$connection = mysql_connect($thehost, $theuser, $thepassword) or die ("Could not connect to MySQL Server");
$db = mysql_select_db($thedatabase, $connection) or die ("Could not select database.");

try copy paste the code blindly... if this still doesn't work, i don't know what will.

Localhost always work if the MySQL are on the same machine. Have you check whether your mysql server is running or not? because that's the most possible cause if nothing still happen. Also try check your mysql variables
 
Back
Top