PHP MySQL Connecting stringConnection to Mysql database can be established by using mysql_connect function. We can check the success of the function by checking the result. We will get a true result in case connection is established. Based on this we can even print a message saying the details.
It is recommended by PHP.NET to use PDO_MySQL or MySQLI extensions. The old MySQL extension was deprecated in PHP 5.5.0 and was removed in PHP 7This function takes three parameters, first one is hostname then user-id and them password. We can give the port number along with the hostname also.
Here is the function to connect to mysql database
mysql_connect ("$servername","$dbuser","$dbpassword");The above function will return true or false depending on the success of the connection. So we will add message to the above function like this.
Mysql_connect once establish the connection the link will be present till the script execution is over. It will close it self once the script execution is over or the function mysql_close() is called.
|More on PHP MySQL functions|
|I think you have a typo.... you define $dbusername='userid' but than further down in your mysql_connect its only $dbuser.. I'm a newbe so maybe there is something else going on|