Note that there are some explanatory texts on larger screens.

plurals
  1. POThe right syntax for insertion into Mysql using php
    primarykey
    data
    text
    <p>I'm trying to insert some values into the database using information posted on a form through php</p> <p>following is the code that i'm using for insertion</p> <pre><code> $query=mysql_query("select * from poll_question where question = '$question'") or die(mysql_error()); $numrows=mysql_num_rows($query); if($numrows) { while($row=mysql_fetch_assoc($query)) { $dbid=$row['id']; } } $sql1 = "INSERT INTO poll_option(option , poll_id ,click) VALUES('$_POST[optionone]', '$dbid' , 0)"; $result1 = mysql_query($sql1); echo "1 record added"; echo mysql_error(); $sql2 = "INSERT INTO poll_option(option , poll_id , click) VALUES('$_POST[optiontwo])', '$dbid', 0)"; $result2 = mysql_query($sql2); echo mysql_error(); $sql3 = "INSERT INTO poll_option(option , poll_id, click) VALUES('$_POST[optionthree])', '$dbid ', 0)"; $result3 = mysql_query($sql3); echo mysql_error(); </code></pre> <p>now i'm getting the following output</p> <pre><code> 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 'option , poll_id ,click) VALUES('sj', '24' , 0)' at line 1 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 'option , poll_id , click) VALUES('dsdg', '24', 0)' at line 1 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 'option , poll_id, click) VALUES('xzf', '24 ', 0)' at line 1 </code></pre> <p>The part under the "values" syntax is the one that i'm trying to insert. that information is correct.that is <strong>VALUES('xzf', '24 ', 0) is Correct</strong> and i want to insert this only , but their is some problem with the syntax.Any suggestions?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload