Forum Moderators: coopster
I have hosted a webser (with mysql). In my mysql, I have create a database named 'member' and password is password. My host is example.com, port: 3306
So I tried connect my DB with the below script:
mysql_connect('example.com:3306', 'member', 'password');
if (!$link) {
die('Database Could not connect: ' . mysql_error());
} else{
echo 'Database Connected successfully';
}
I receive the message 'Database Could not connect'
Is it any wrong with my script? Anyone can help?
[edited by: eelixduppy at 3:44 am (utc) on Nov. 25, 2007]
[edit reason] removed specifics [/edit]
$host="example.com:3306"; // Host name
$username="your_username"; // Mysql username
$password="password"; // Mysql password
$db_name="member"; // Database name
$connection = mysql_connect("$host","$username","$password")or die("cannot connect");
$db = mysql_select_db("$db_name")or die("cannot select DB");
You can either put your direct values in place of the variables like you were doing with your code, or you can use it like this.
[edited by: eelixduppy at 3:45 am (utc) on Nov. 25, 2007]
[edit reason] removed specifics [/edit]
$link = mysql_connect('example.com:3306', 'member', 'password');
if (!$link) {
die('Database Could not connect: ' . mysql_error());
} else{
echo 'Database Connected successfully';
}#Onto select the database with mysql_select_db()...