Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,
I got to develop my whole database in Wampserver 2.1 (it's the latest set). But now I cannot connect to MySQL through PHP in Wamp. I have searched a lot but still have no clue as to what is...

I have tried a number of code combination including "if(!)" and nothing has worked.
CAN ANYONE HELP PLEASE.

Here is the current code I am trying which returns blank page:
PHP
$mysql_hostname="localhost";

$mysql_database="naveena";

$bd=mysql_connect($mysql_hostname) or die('DB not Connected');

if(!$bd)
{
echo "Localhost not connected";
}

mysql_select_db($mysql_database,$bd);
if(!mysql_select_db($mysql_database,$bd))
{
echo "DB not connected";
}
?>
Posted
Updated 26-Nov-16 23:07pm
v2

PHP
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
 
Share this answer
 
mysql_connect('host_name', 'username', 'password');

I have answered the same type question in here...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900