Connect to MySql from PHP

By Santhosh N

This explains how to connect to MySql from PHP

mysql_connect is the method used to connect to the mysql from php and it takes three parameters namely host, username and password of the mysql instance.

   $mshost = 'localhost';
   $msuid = 'user';
   $mspwd = 'password';
   $mscon = mysql_connect($mshost, $msuid, $mspwd);
   if( $mscon )
     echo 'Connected successfully';

Related FAQs

This explains how to set root password for MySql Database
MySql as we ll aknow is a light weight DB compared to major databases like sql server and oracle and its now competing with others with the introduction of support of stored procedures
A php server script block can be written in shorter format without using php name
Connect to MySql from PHP  (838 Views)