plz help me.i am developing a webpage .i want to connect mysql database by using php .i did connection code in php. but i did't get the connection.
here i am attach what i did. if any one knows how to connect mysql database plz send the answer.
$dbhost = "localhost";
$username = "root";
$password = "";
$dbname = "test";
$conn = mysql_connect($dbhost,$username,$password) or die ("db error");
$select_db = mysql_select_db($dbname) or die ("cloud not select db");
$db=mysql_select_db("test",$conn);
$query=mysql_query("select * from local_bus",$db);
?>
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Aug 2, 2015, 11:17 PM EDT
//ENTER YOUR DATABASE CONNECTION INFO BELOW:
$hostname="db1111111111.db.1and1.com";
$database="db1111111111";
$username="dbo111111111";
$password="myPassword";
//DO NOT EDIT BELOW THIS LINE
$link = mysql_connect($hostname, $username, $password);
if (!$link) {
die('Connection failed: ' . mysql_error());
}
else{
echo "Connection to MySQL server " .$hostname . " successful!
" . PHP_EOL;
}
$db_selected = mysql_select_db($database, $link);
if (!$db_selected) {
die ('Can\'t select database: ' . mysql_error());
}
else {
echo 'Database ' . $database . ' successfully selected!';
}
mysql_close($link);
?>
Sandeep KumarRank #1,923 · 763 reputationPosted Aug 11, 2015, 5:06 AM EDT
}
if (!mysql_select_db("
throw new Exception("No contacts database found on database server.");
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Aug 15, 2015, 11:40 PM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts