Note that there are some explanatory texts on larger screens.

plurals
  1. POInsert row to MySQL Table using PHP Form
    text
    copied!<p>I would like a user to be able to insert a "bid" into a MySQL table using a php form - this is only for demo, not live purpose. I get the following error message, </p> <p>Error: 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 ''90','2011-07-13'' at line 3 (Line 3 refers to my tag?) I figure it doesnt like the form inputs just being "text" type, but no idea how to fix it - all advice very welcome, this is my form &amp; php code below;</p> <pre><code>&lt;form action="insert.php" method="post"&gt; &lt;div&gt;&lt;label for="commodity"&gt;Commodity&lt;/label&gt;&lt;input type="text" name="commodity"/&gt;&lt;/div&gt; &lt;div&gt;&lt;label for="region"&gt;Region&lt;/label&gt;&lt;input type="text" name="region"/&gt;&lt;/div&gt; &lt;div&gt;&lt;label for="member"&gt;Member&lt;/label&gt;&lt;input type="text" name="member" /&gt;&lt;/div&gt; &lt;div&gt;&lt;label for="size"&gt;Size&lt;/label&gt;&lt;input type="int" name="size" /&gt;&lt;/div&gt; &lt;div&gt;&lt;label for="price"&gt;Post Bid&lt;/label&gt;&lt;input type="decimal" name="price" /&gt;&lt;/div&gt; &lt;div&gt;&lt;label for="posted"&gt;Date Posted&lt;/label&gt;&lt;input type="text" name="posted"/&gt;&lt;/div&gt; &lt;P&gt;&lt;label for="submit"&gt;Submit Bid&lt;/label&gt;&lt;input type="submit" /&gt;&lt;/P&gt; &lt;/form&gt; </code></pre> <p>&amp; php</p> <pre><code>&lt;?php $con = mysql_connect("localhost","",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("palegall_newTrader", $con); $sql="INSERT INTO `buy` (commodity, region, member, size, price, posted) VALUES ('$_POST[commodity]','$_POST[region]','$_POST[member]','$_POST[size]','$_POST[price]','$_POST[posted]'"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con) ?&gt; </code></pre> <p>Many thanks in advance, scotia </p>
 

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