The below mentioned command is used for the mysql connection test.
1. Touch a php file for example
    connection.php
2. Coppy paste below mentioned code in that file
========================================================================
<?php
        ############ Define hostname #############
        ## Replace "localhost" with your mysql host name or Ip address ##
         define ("HOSTNAME","localhost");
        ############ Define username ###################
        ## Replace "db_usname" with your Database Username ##
        define ("USERNAME","username");
        ############ Define password ###################
        ## Replace "db_passwd" with your Database password ##
        define ("PWD","password");
        ############ Define database ###################
        ##Replace "db_name" with your Database name ##
        define ("DBNAME","dbname");
        ####link to mysql server####
        if($link = mysql_connect (HOSTNAME,USERNAME,PWD))
                {
                        print "<h3>Sucessfully connected to the MySQL server</h3><br />\n";
                }
                else
                {
                        die ("<h3>Cannot connect to MySQL server.</h3><br />\n" . mysql_error());
                }
if (mysql_select_db (DBNAME , $link))
                {
                  print "<h4>Connection to Database Successful</h4><br />\n";
                }
                else
                {
                        die ("<h4>Cannot select database.</h4><br />\n" . mysql_error());
                }
?>
========================================================================
3. Dont foget to change the ownership
No comments:
Post a Comment