Reputation: 537
here is my code
$db_handle = mysql_connect('127.0.0.1', 'root', '123456');
if(!$db_handle)
die(mysql_error())
when i was debugging the code just got a page with "This page can't be display", and the a pop up message from netbean said " Socket Exception occured", can anyone help? thanks
edit new code:
$db_handle = new PDO('mysql:host=localhost;dbname=test','admin','123456');
if($db_handle)
echo 'connected';
it works, but the mysqli didn't work either
Upvotes: 0
Views: 105
Reputation: 537
$db_handle = new PDO('mysql:host=localhost;dbname=test','admin','123456'); if($db_handle) echo 'connected';
Upvotes: 0
Reputation: 23510
Please stop using mysql_query
for new project, use mysqli or PDO
Here a sample:
mysqli = new mysqli($host, $user, $dbpassword, $database);
if (mysqli_connect_errno())
{
printf("Connection failed: %s\n", mysqli_connect_error());
exit();
}
Upvotes: 1