answersLogoWhite

0


Best Answer

To close your MySQL database connection you need to use the mysql_close() function. Please see the example below:

<?php

mysql_close();

?>

If your connection data is stored in a variable you would close the connection like this instead:

<?php

mysql_close($db_conn);

?>

That's useful for if you're using more than one database connection in a PHP script.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you close a MySQL database connection using PHP?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you connect to mysql using vb6?

Install the MyODBC database connector.Set up an new ODBC connection to your mysql database in Windows. (This will vary based on your version of Windows)You can use the ADODB extension in VB to connect to your ODBC connection.


How do you create a database using PHP?

The following are the fundamental procedures for creating a MySQL database with PHP: As demonstrated in this article, connect to the MySQL server from your PHP script. If the connection is successful, construct a database using SQL and save it in a string variable. Carry out the query. To learn more about data science please visit- Learnbay.co


What is offered by MySQL Connect?

Connection to MySQL Using PHP Script To open a database connection, PHP provides the mysqli construct or the mysqli connect() function. On success, this method returns a MySQL link identification; on failure, it returns FALSE. To learn more about data science please visit- Learnbay.co


I have installed MySql server and SQL Maestro for MySql.If i create a new database in mysql maestroit gives Sql access denied for rootlocalhost passwordno.how do i make a connection bween that.?

connect it using a cable line


How you can take backup of database in mysql?

It is quite easy to back up a database using dbForge Studio for MySQL. To do this, open the tool and connect to the MySQL server. In the database explorer, right-click the database you want to back up and select Backup and Restore &gt; Database Backup. Additionally, the tool allows you to automate the backup process using Task Scheduler.


What are the advantages and disadvantages of PHP with mysql?

Ultimately PHP is a programming language and MySQL is a database language. Using PHP with MySQL is a nice combination with built-in support and the simplicity of it all. However, there aren't a lot of disadvantages of using PHP with a database, it just allows for better data organization and whatnot. There are definitely advantages and disadvantages to using a database other than MySQL (such as MongoDB or PostgreSQL).


How do you search from database using ASP?

There are thee basic steps: Obtain the connection string and open the connection to the database Prepare your query and execute it, retrieving the result into a dataset Close the connection


How do you retrieve the data from database?

To retrieve data rfrom a mysql database you first need to connect to the database using the mysql connection string(mysql_connect) after that, it's just a matter of executing a query of "SELECT `field1`, `field2` FROM `tablename`" Obviously replacing field 1 and 2 with the fields you want to replace and tablename with the table the data is stored


How do you retrieve an image from a database using PHP?

It depends what Database you are using. I personally use MySQL so will explain how you would do it using MySQL. You would have to create the MySQL database. I would store the image URL rather than the actual image. Then call it using PHP and a MySQL query. For Example: $sql = "SELECT * FROM Images WHERE Img_Name = 'img1'"; $query = mysql_query($sql); $array = mysql_fetch_array(query); then you would call it into HTML like so:


What does mysql error failed to establish connection with mysql server mean?

This is an error in MySQL that occur due to various reasons: MySQL database has been corrupted. Wrong database credentials. MySQL Server (Web Host) is not responsive. But the most common reason of this error is database corruption and for fixing the error occured because of this reason you can make use of a tool named Stellar Repair for MySQL that safely restores all inaccessible database objects including primary keys, views, triggers, tables, etc. in the original format. The tool also provides preview of recoverable database objects in main interface. You can fix this error easily using this tool for free from Stellar's Official Site.


What are some MYSQL backup methods?

Some of the methods for backups using the MYSQL method are to download programs specifically for ones needs like AutoMySQLBackup. To manually backup the database, the 'noupe' website offers information on how to do this.


How do you connection database in HTML using javascript?

Connection Database can be established using language such as Java. For that you need to create an object of Connection type.