<?php
$fname=$_POST['fname'];
$mname=$_POST['mname'];
$lname=$_POST['lname'];
$college_name=$_POST['college_name'];
$semester=$_POST['semester'];
$contact=$_POST['contact'];
$email=$_POST['email'];
$dbc = mysql_connect('localhost','XXXX',"XXXX",'XXXXX')
or die('error connecting to MYSQL server');
echo kkk;
$query = "INSERT INTO tab_m_registration(fname, mname, lname, college_name, semester, contact, email)".
"VALUES(`$fname`, `$mname`, `$lname`, `$college_name`, `$semester`, `$contact`, `$email`)";
echo $query;
$result=mysql_query($query,$dbc) or die('error querying database');
echo $result;
echo 'Thanx for submitting the form. <br/>';
mysql_close($dbc);
?>
Actually I don't understand where is the problem.
$result = mysql_query($query, $dbc)
is not working I think.
I first tried mysqli_query()
and it got problem. Then I tried this
$result = mysql_query($dbc, $query)
and I get an error "argument 1 should be string" in mysql_query()
.
I swapped the values and finally used this mysql_query($query, $dbc)
.
It shows the value passing through echo.
But still there's a problem inserting the data in the database table. Please help me out.