0

I have a file config.php

<?php

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

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

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:

mysql_close($connection);

but it gives me error, please advise.

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

3
  • 5
    Mixing mysql with mysqli!! Commented Aug 17, 2016 at 12:43
  • 4
    Additionally, using $connect and $connection? Commented Aug 17, 2016 at 12:45
  • what is the error message? Commented Aug 17, 2016 at 13:13

3 Answers 3

1

Try this code

mysql_close($connect);
Sign up to request clarification or add additional context in comments.

Comments

0

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

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

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

Comments

0

You should use mysqli because mysql is not supported anymore in PHP latest version. and you are trying to close database connection with mysqli. use like this.

mysql_close($connect);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.