Here is my code:
The include file contains the database info.Code:<?php session_start(); include ("Includes/database_info.php"); mysql_select_db("a1401476_records", $con); $sql="INSERT INTO products (Title, Description, Seller, Picture, Condition, Price, Country, Province, City, School, Campus, Grade, Class) VALUES ('$_POST[title]','$_POST[description]','$_SESSION[username]','$_POST[image]','$_POST[condition]','$_POST[price]','$_POST[country]','$_POST[province]','$_POST[city]','$_POST[school]','$_POST[campus]','$_POST[grade]','$_POST[class]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con); ?>
Here is my html form.
I am getting an error when i submit the form and no it shouldn't be related to the length of the input...Code:<div> <form action="sell.php" method="post"> <b>Seller's Username</b>: <?php echo $_SESSION['username']; ?> <br /><a href="logout.php">If you are not <?php echo $_SESSION['username']; ?> then click here to logout.</a><br /><br /> <b>Title</b>: <input name="title" type="text"></input> <br /> <b>Short Description</b>:<br /> <textarea name="description" rows="5" cols="25"></textarea> <br /><br /> <b>School</b>: <input name="school" type="text"></input><br /> <b>Campus</b>: <input name="campus" type="text"></input><br /> <b>Grade</b>: <input name="grade" type="text"></input><br /> <b>Class</b>: <input name="class" type="text"></input><br /> <br /> <b>Condition</b>: <select name="condition"> <option value="excelent">Excelent</option> <option value="good">Good</option> <option value="poor">Poor</option> </select> <br /><br /> <b>Price</b>: <b>$</b><input name="price" type="text"></input><br /><br /><br /> <p>If you choose to include an image then upload the image to a file sharing site such as <a href="http://www.photobucket.com">Photobucket</a>, then supply the direct link below.</p> <b>Image of Textbook</b>: <input name="image" type="text"></input> <br /><br /> <input type="submit" value="Sell your Textbook"></input> </form> </div>
Error:
I used this exact code with a few modifications for my register/login page and it worked perfectly. What is wrong? It works fine if you just enter regular strings but i need to be able to use $_POST.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 'Condition, Price, Country, Province, City, School, Campus, Grade, Class) VALUES' at line 1




Reply With Quote