Jump to content

[SOLVED] Small insert problem


waynewex

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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.