0

I have website I was build it from scratch using PHP/MYSQL but unfortunately I got a lot of mysql DB disconnect "not conect", I'm sure about DB Name, user and Password .. My config file below :

$conectdb = mysql_connect("localhost","user","pass") or die ("not conect");
mysql_set_charset('utf8',$conectdb);
$selectdb = mysql_select_db("DB_name",$conectdb)or die ("selected DB");
$charset = mysql_client_encoding($conectdb);
header('X-Frame-Options: SAMEORIGIN');
  • 4
    If you can, you should [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). [These extensions](http://php.net/manual/en/migration70.removed-exts-sapis.php) have been removed in PHP 7. Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) statements for [PDO](http://php.net/manual/en/pdo.prepared-statements.php) and [MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) and consider using PDO, [it's really not hard](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Oct 12 '15 at 16:05
  • Stop `die()`ing on a connection error, instead have a look at what `mysql_error` says, enable `error_reporting` in your PHP.ini and look for any suspicious error messages. And, of course, what Jay said. – helmbert Oct 12 '15 at 16:10
  • use this `mysql_error()` to find any errors. However, as @JayBlanchard said. Do yourself a favor and change to mysqli or PDO. – CodeGodie Oct 12 '15 at 16:10

0 Answers0