Adscend

Click Here



Click Here



Click Here

Tuesday 3 September 2013

mysql_select_db() Function

mysql_select_db() Function


1.mysql_select_db() function is used to select existing database on the server associated with the specified link identifier.
2.If no link identifier is specified, the last opened link is assumed.
3.mysql_select_db() function returns TRUE on success or FALSE on failure.

Syntax
bool mysql_select_db(database_name,connection)

Here, database_name specifies the database to select.
connection is optional. If not specified, the last connection opened by mysql_connect().
Example
<?php
$hostname = "localhost";
$username = "root";
$password = "";
$con = mysql_connect("$hostname", "$username", "$password");
if(! $con )
{
die("Could not connect: " . mysql_error());
}
echo "Connected successfully";
// select current db
$db_selected = mysql_select_db("Aspell", $con);
if (!$db_selected) {
die ("Can\'t select : " . mysql_error());
}
mysql_close($con);
?>
Output
Connected successfully



No comments:

Post a Comment