PHP5/MySQL connection string
Posted: Fri Jul 25, 2008 12:41 pm
hello all...
i'm getting the following error from the connection string below (PHP 5.2.6, Apache 2.2.9, MySQL5, Win Vista Home)
\n"); print(mysql_errno() . ": "); print(mysql_error() . "
\n"); commonErrors(); exit(); } ?>
dbname, user and pw all tested in MySqlAdmin and are valid
thanks very much
Conor
i'm getting the following error from the connection string below (PHP 5.2.6, Apache 2.2.9, MySQL5, Win Vista Home)
\n"); print(mysql_errno() . ": "); print(mysql_error() . "
\n"); commonErrors(); exit(); } ?>
dbname, user and pw all tested in MySqlAdmin and are valid
thanks very much
Conor
Code: Select all
<?
// This should remain localhost unless specifically connecting to a remote database.
$dbhost = "localhost";
// The database name should be the same as the hosting account username.
$dbname = "mydb";
// The database username should be the same as the hosting account username.
$dbuser = "root";
// The database password should be the same as the hosting account password.
$dbpass = "****";
// Establish the connection to database
if(!($dblink = mysql_connect("$dbhost", "$dbuser", "$dbpass")))
{
// Unable to connect to database so print an error
print("Unable to connect to the MySQL database server!\n");
commonErrors();
exit();
}
// Select the database to use
if(!(mysql_select_db("$dbname", "$dblink")))
{
// Unable to select the database
print("Unable to select the $dbname database!<br>\n");
print(mysql_errno() . ": ");
print(mysql_error() . "<br>\n");
commonErrors();
exit();
}
?>