Please help with database connection.
I'm attempting to connect to mysql db from php for the first time, and I keep getting the following error:
Warning: Access denied for user: 'mysql@mysysname.org' (Using password: YES) in /home/user/public_html/main.php on line 65
Error connecting db server
The following code is included in my php file:
$HOST = "mysysname:3306";
$ID = "mysql";
$PWD = "mypasswd";
$db = mysql_pconnect($HOST,$ID,$PWD);
if (!$db) echo "Error connecting db server";
else
echo "Connected to db server";
if (!mysql_select_db("DB_name",$db))
{
echo "Error selecting database";
exit;
}
else
{
mysql_select_db('DB_name',$db);
}
$query = "SELECT fname, lname FROM main WHERE fname = $fname AND
lname = $lname";
@$result = mysql_query($query,$db);
if ($result)
{
echo "Query error! - A user with this exact first and last name already exists.";
}
else
{
$query = "INSERT into main values ($fname, $lname, $gender, $dob, $race, $cntry_birth, $height, $metric1, $weight, $metric2, $ecolor, $hcolor, $status, $age)";
}
I'm not able to connect to db.
I verified that the password is correct but I'm not sure about syntax or commands used.
Any help would be much appreciated.
Thanks in advance.
Irina
I'm attempting to connect to mysql db from php for the first time, and I keep getting the following error:
Warning: Access denied for user: 'mysql@mysysname.org' (Using password: YES) in /home/user/public_html/main.php on line 65
Error connecting db server
The following code is included in my php file:
$HOST = "mysysname:3306";
$ID = "mysql";
$PWD = "mypasswd";
$db = mysql_pconnect($HOST,$ID,$PWD);
if (!$db) echo "Error connecting db server";
else
echo "Connected to db server";
if (!mysql_select_db("DB_name",$db))
{
echo "Error selecting database";
exit;
}
else
{
mysql_select_db('DB_name',$db);
}
$query = "SELECT fname, lname FROM main WHERE fname = $fname AND
lname = $lname";
@$result = mysql_query($query,$db);
if ($result)
{
echo "Query error! - A user with this exact first and last name already exists.";
}
else
{
$query = "INSERT into main values ($fname, $lname, $gender, $dob, $race, $cntry_birth, $height, $metric1, $weight, $metric2, $ecolor, $hcolor, $status, $age)";
}
I'm not able to connect to db.
I verified that the password is correct but I'm not sure about syntax or commands used.
Any help would be much appreciated.
Thanks in advance.
Irina