What is mysql select db in PHP
In this article I am going to explain about mysql_select_db function in PHP.
PHP mysql_select_db() Function
The PHP mysql_select_db function is used to select a MySQL database.
Syntax of mysql_select_db function
mysql_select_db(database, connection) |
Parameters in mysql_select_db function
It have two parameter:
Parameter |
Description |
database |
It specifies database name to select. |
connection |
It specifies MySQL connection. |
Example of mysql_select_db function
<?php
$con=mysql_connect("localhost","gupta","sharad");
if(!$con)
{
die("Could not connect:".mysql_error());
}
$dbSelect=mysql_select_db("mcn_solution");
if(!$dbSelect)
{
die("Database is not present: ".mysql_error());
}
else
{
echo "Database is present";
}
mysql_close($con);
?>
|
Output
You may also want to read these related articles :here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here