Basic syntex:
<?php
$con= mysql_connect("xyz.com","pan","pan123","my_db");
if(!con){
echo "Could not connect to database".mysql_connect_error();
}
?>
mysql_connect("hostname","usename","password","dbname")
Example:<?php
$con= mysql_connect("xyz.com","pan","pan123","my_db");
if(!con){
echo "Could not connect to database".mysql_connect_error();
}
?>
2 comments:
Hi Pankaj,
There is a bug in your code...You cannot use dbname in mysql_connect..
For that you have to use Mysqli to use that is mysqli_connect
Please switch to mysqli as mysql is going to be deprecated
Happy coding:)
Thank you for all your help Dharmesh mallah......I have updated code as below
Basic syntex:
mysqli_connect("hostname","usename","password","dbname")
Example:
Post a Comment