WooLf WooLf - 1 year ago 144
MySQL Question

PHP close MySQL connection

I have a file config.php


$dbhost = "*****";
$dbname = "*****";
$dbuser = "*****";
$dbpassword = "*****";

$connect = mysql_connect("$dbhost","$dbuser","$dbpassword");

mysql_query("SET NAMES 'utf-8'");

And i have file insert.php with inserting form values into MySql.
At the end of this file i am trying to close database connection with:


but it gives me error, please advise.

P.S: I am very new to php so please don't blame.

Answer Source

You are using mysqli_close($connect) instead of mysql_close($connect);

$connect = mysql_connect("$dbhost","$dbuser","$dbpassword");

I would suggest you to move your code to mysqli because mysql is not supported anymore in php7

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download