hi
i want to know whether my coding is correct because data is not getting inserted in my sql table,but it is displaying the "data inserted" message<html>
<head></head>
<body>
<?php
$uname1= $_POST;
$cname=$_POST;
$caddr=$_POST;
$mid=$_POST;
$skills=$_POST;
$degree=$_POST;
$indtype=$_POST;
$desc=$_POST;
$req=$_POST;
$yoe=$_POST;
$sal2=$_POST;
$search=$_POST;
$hostname = "localhost";
$username = "uname";
$password = "godcares";
$dbid = "splendor_samp";
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die("unable to connect");

if (isset($_REQUEST["Submit"]))
{
mysql_query("INSERT INTO postreq(uname,cname,caddr,mailid,skills,degree,indtype,desc,req,yoe,sal,searchdate)VALUES('$uname1','$cname','$caddr','$mid','$skills','$degree','$indtype','$desc','$req','$yoe','$sal2','$search')");
echo "data inserted";
}
else
{
echo "ERROR: ".mysql_error();
}
mysql_close($link);
?>
</body>
</html>

try changing this one: if (isset($_REQUEST["Submit"])) with this one: if ($_POST('Submit'))

hi
it is displaying error message like this
RROR:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc,req,yoe,sal,searchdate)VALUES('jhj','hjhg','hjhg','hjghj','hjhj','hjhj','hj' at line 1

Have you tried running your query in MySql?I think the problem there is the query itself,e.g. wrong fields,wrong field type,etc.for example your searchdate is supposed to be a date therefore you must enter a date.Try to check on this one.

thanks for your reply ...i found the error...desc is a key word in sql...i have given the name to my field in the table......

ok,please mark your thread as solved!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.