waynew Posted November 18, 2008 Share Posted November 18, 2008 Okay, basically, I'm allowing users to insert orders into a database. Problem is, the price variable doesn't seem to end up in the database, even though it is coming through the POST and making its way into the query. The table column amountPaid is set to double. $session_id = session_id(); $data_ok = true; //assumed true unless proven otherwise if (isset($_POST['book']) && $data_ok){ $event = mysql_real_escape_string($_POST['event']); $date = mysql_real_escape_string($_POST['date']); $time = mysql_real_escape_string($_POST['time']); $datetime = $date.' '.$time; $num_children = mysql_real_escape_string($_POST['num_children']); $num_adults = mysql_real_escape_string($_POST['num_adults']); $price = mysql_real_escape_string($_POST['price']); echo $price; $insert = mysql_query(" INSERT INTO Orders (sessionId,eventId,noChildren,noAdults,dateTime,amountPaid) VALUES ('$session_id','$event','$num_children','$num_adults','$datetime',$price)") or die(mysql_error()); } Link to comment https://forums.phpfreaks.com/topic/133175-solved-small-insert-problem/ Share on other sites More sharing options...
MasterACE14 Posted November 18, 2008 Share Posted November 18, 2008 $insert = mysql_query(" INSERT INTO Orders (sessionId,eventId,noChildren,noAdults,dateTime,amountPaid) VALUES ('$session_id','$event','$num_children','$num_adults','$datetime','$price')") or die(mysql_error()); Should work now. You were missing the single quotes around $price in the query. Regards, ACE Link to comment https://forums.phpfreaks.com/topic/133175-solved-small-insert-problem/#findComment-692601 Share on other sites More sharing options...
waynew Posted November 18, 2008 Author Share Posted November 18, 2008 Sorry, I had removed them when trying to debug. No, I'm just after finding out that the problem doesn't rest in the insert; it rests in the output. Whoops. Thanks anyway. Link to comment https://forums.phpfreaks.com/topic/133175-solved-small-insert-problem/#findComment-692603 Share on other sites More sharing options...
MasterACE14 Posted November 18, 2008 Share Posted November 18, 2008 Well your script looks fine. Try adding error_reporting(E_ALL); to the top of the script and see what comes up. Link to comment https://forums.phpfreaks.com/topic/133175-solved-small-insert-problem/#findComment-692604 Share on other sites More sharing options...
waynew Posted November 18, 2008 Author Share Posted November 18, 2008 It's ok, I found the problem. Basically, the column is called amountpaid and not amountPaid. The programmer before me had kept with the camelback naming convention throughout all of his columns... expect for that one column. Thanks! Link to comment https://forums.phpfreaks.com/topic/133175-solved-small-insert-problem/#findComment-692611 Share on other sites More sharing options...
MasterACE14 Posted November 18, 2008 Share Posted November 18, 2008 that certainly explains it then lol. Hit topic solved (bottom left) Link to comment https://forums.phpfreaks.com/topic/133175-solved-small-insert-problem/#findComment-692614 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.