patheticsam Posted March 26, 2010 Share Posted March 26, 2010 Hi! I just a small form to insert some data into a MYSQL database and can't get it working...The weird thing is that I use the same script in other sections on my website and it works perfectly so if anyone can figure what i'm doing wrong...... here's the form code (pretty simple) : <form id=\"order\" name=\"order\" method=\"post\" action=\"members/order.php\"> <input type=\"hidden\" name=\"itemid\" id=\"itemid\" value=\"".$info['item_id']."\"> <input type=\"hidden\" name=\"status\" id=\"status\" value=\"Unconfirmed\"> <input type=\"hidden\" name=\"payment\" id=\"payment\" value=\"Not received\"> <a href=\"members/order.php\"><img src=\"../img/buynow.jpg\" alt=\"Acheter\" /></a> </form> And here's the order.php part : <?php require_once('auth.php'); ?> <?php //Start session session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="fr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <link href="../css/style2.css" rel="stylesheet" type="text/css" /> <title>LVA ENTERTAINEMENT</title> </head> <body> <?php $con = mysql_connect("localhost","login","pass"); $member = $_SESSION['SESS_MEMBER_ID']; $itemid = mysql_real_escape_string($_POST['itemid']); $status = mysql_real_escape_string($_POST['status']); $payment = mysql_real_escape_string($_POST['payment']); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("DB", $con); $sql="INSERT INTO order ( item_id, member_id, status, payment) VALUES ('$member','$itemid','$status','$payment')";if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "<br /><br /><center>Votre artiste a correctement été ajouté à la base de donnée.<br /><br /><a href=\"../dashboard.php\" target=\"main2\">Retour au paneau de contrôle</a></center>"; ?> </body> </html> Please help! Link to comment https://forums.phpfreaks.com/topic/196609-weird-problem-with-insert-script/ Share on other sites More sharing options...
patheticsam Posted March 26, 2010 Author Share Posted March 26, 2010 Here's the error I'm getting : 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 'order ( item_id, member_id, status, payment) VALUES ('4','','','')' at line 1 (We can see that the form is not passing out the values.....) Link to comment https://forums.phpfreaks.com/topic/196609-weird-problem-with-insert-script/#findComment-1032281 Share on other sites More sharing options...
Kieran Menor Posted March 26, 2010 Share Posted March 26, 2010 The problem might be your table name. ORDER is a MySQL keyword. Try enclosing it in backquotes, alike so: $sql="INSERT INTO `order` ( item_id, member_id, status, payment) VALUES ('$member','$itemid','$status','$payment')"; Link to comment https://forums.phpfreaks.com/topic/196609-weird-problem-with-insert-script/#findComment-1032282 Share on other sites More sharing options...
patheticsam Posted March 26, 2010 Author Share Posted March 26, 2010 Ok it fixed the SQL problem but still member_id, status, payment values are not passed from the form to order.php.....Any ideas why????? Link to comment https://forums.phpfreaks.com/topic/196609-weird-problem-with-insert-script/#findComment-1032284 Share on other sites More sharing options...
patheticsam Posted March 26, 2010 Author Share Posted March 26, 2010 crrection : Member_id is correctly inserted cause of the SESSION.......item_id, status and payment is not received from the form..... Link to comment https://forums.phpfreaks.com/topic/196609-weird-problem-with-insert-script/#findComment-1032289 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.