Jump to content

[SOLVED] Small insert problem


waynew

Recommended Posts

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

	

$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

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.