PHP and MYSQL insert data into table

, by Prashant Gunjal

<html>
<head>
    <title>PHP and MYSQL insert into table </title>
</head>
<body>
<?php
    $con = mysql_connect("localhost","root");
    if($con)
    {
        echo "<br> Connected succesfully !!!";
        mysql_select_db("my_DB");    //Use existing database for creating new table

        if(mysql_query("insert into student values (1,'Prashant');",$con))
            echo "<BR>Values inserted successfully";
        else
            echo mysql_error();
        mysql_close($con);
    }
    else
        echo "<br>Connection error .... ".mysql_error();
?>
</body>
</html>

Befor running --

Now running program :





Changes in database :




0 comments: