I can connect to my database just fine when I'm on my website, but when I'm on my notepad++, and I tried to connect to my database, I get the error below. I have XAMPP installed, and apache is working smoothly, but the only thing is that I can't connect to the database while in the notepad++, and yet it works when I'm on my website. All the files are copied from my website, so there is no discrepancy between the files on my website, and the files on my notepad++. I use localhost to get to the index of my page using notepad++, and it works fine. Only when I tried to register information to my database did the error below show up. Please help. Thanks.
Warning: mysql_connect(): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in E:\xampp\htdocs\iscattered\register.php on line 3 Not connect :A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
<?php
$var = mysql_connect('mysql2.000webhost.com','username','password');
if(!$var){
die('Not connect :' . mysql_error());
}
$database = mysql_select_db("database",$var);
if(!database){
die("Can't connect : " . mysql_error());
}
?>
Aucun commentaire:
Enregistrer un commentaire