Am trying to connect with my database using php from my website. I have used following codes to make connection,
mysql_connect($db_host,$db_username,$db_pass) or die("Could not connect to my sql");
mysql_connect($db_name) or die("No Database");
But when i run the file in my website it shows the following error...
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator to inform of the time the error occurred and of anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
What was the issue and where I made mistake?
don't use mysql its already deprecated use MySQLI or PDO instead..
USING MySQLI you can connect to your server just doing this..
define('HOST','10.12.209.82'); define('USER','username'); define('PASSWORD','password'); define('Database','dbname'); $dbh = mysqli_connect(HOST,USER,PASSWORD,DATABASE) or die('Cannot connect to the server');
Should be (mysql_select_db):
$db_host="localhost"; $db_username="root"; $db_pass="302010asd"; $db_name="mvnodb"; mysql_connect($db_host, $db_username, $db_pass) or die("Could not connect to my sql"); mysql_select_db($db_name) or die("No Database");
Invoking mysql_connect again and not supplying properly parameters raises a error.