Reputation: 4557
I am trying to store data into database. if i am using the following code
$sql="INSERT INTO rohit(content,tags,uniquefield,required)
VALUES('$l','$y','$z','$t')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
it is running but when i am adding one more field then it is giving error check mysql syntax
$sql="INSERT INTO rohit(content,tags,uniquefield,required,numeric)
VALUES('$l','$y','$z','$t','$n')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
i have defined all the fields in database. what may be the possible error
Upvotes: 1
Views: 92
Reputation: 6030
because you are trying to add a string value to the numeric field and I guess that the type of that columns is not a string, because of the name
Upvotes: 1
Reputation: 219824
numeric
is a reserved word. Place it in tics to escape it:
$sql="INSERT INTO rohit(content,tags,uniquefield,required,`numeric`)VALUES('$l','$y','$z','$t','$n')";
Upvotes: 4