Showing results for 
Show  only  | Search instead for 
Did you mean: 

database connection using mysql

i have created a database chinnour,table stud. I want to connect the database with the php code.

in cpanel i have written the php code.

    //Sample Database Connection Syntax for PHP and MySQL.
    //Connect To Database
    $yourfield = "empid";
    echo "12 ";
    mysql_connect($hostname,$username, $password) or die ("<html><script language='JavaScript'>alert('Unable to connect to database! Please try again later.'),history.go(-1)</script></html>");
    echo "2 ";
    # Check If Record Exists
    $query = "SELECT * FROM $usertable";
    $result = mysql_query($query);
        while($row = mysql_fetch_array($result)){
            $name = $row["$yourfield"];
            echo "Name: ".$name."<br/>";