Jump to content

[SOLVED] cannot insert into db, getting mysql error


Dirty-Rockstar

Recommended Posts

test1.php

 

<?php
include('sidebar.php');


print "
<center><table>
<tr>
<td><form action=test.php method=post>Item name:</td>
<td><input type=text name=itemname></td>
</tr>
<tr>
<td>description: </td>
<td><input type=text name=description></td>
</tr>
</table>


<input type=submit value=Submit></form>";

print "</body></html>";
?>

 

test.php

 


<?
include('sidebar.php');

print "$_POST[itemname] <br /> $_POST[description]<br />";

$iteminsert1="INSERT INTO items (itemname, description) VALUES ( '{$_POST['itemname']}','{$_POST['description']}'";
$iteminsert2=mysql_query($iteminsert1) or die(mysql_error());



if ($iteminsert2)
{
print "Inserted";
}else{
Print "didnt work";
};
?>

 

 

Result:

 

item

weeeeeeeee

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 '' at line 1

 

table fields:

itemID (bigint20) (auto increment)

itemname (text)

description (text)

 

 

I cant figure it out--thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.