I am able to connect to the database by using the following code.
<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
echo "Connected...!";
?>
But, the above code is just to check whether the connection from PHP to MySQL server is established or not but its no way checking whether the database user is connected with the database name.
Well, I was trying to connect to the database in my project I am unable to connect to it. I have customized error report for that which is not clear but I am able to connect to the database server from PHP using
mysql_connect(servername,username,password);
So, can anybody suggest me some code to test whether the database user is authorized to connect to the database or not?
mysql_select_db()but you should use the mysqli extension instead. will prepare an examplemysqlias themysqlextension you're currently using is deprecated.mysql_extensions are deprecated in PHP 5.5! Use PDO or MySQLi instead. They're nicer.