Showing posts with label Inserting recording in php. Show all posts
Showing posts with label Inserting recording in php. Show all posts

Saturday, 21 January 2012

inserting records in PHP after Connection

<?php
$username = "root";
$password = "";
$hostname = "localhost";
$studentname=$_GET["stname"];
$studentimage=$_GET["stimage"];
$studentquestion=$_GET["stquestion"];
$studentanswer=$_GET["stanswer"];

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
  or die("Unable to connect to MySQL");
//echo "Connected to MySQL now you can create Table new one  <br>";
//select database
mysql_select_db("student_db",$dbhandle);
//echo "data Base Selected";
//command to be run by the DBMS  Mysql or ACESS
$query = "insert into student(student_name,student_image,student_question,answer_question) values('$studentname','$studentimage','$studentquestion','$studentanswer')  ";
// run the query and store the results in the $result variable.
mysql_query($query,$dbhandle) or die("cannot do the query");
?>