View Single Post
Old 11-08-2012, 09:32 PM   PM User | #1
oddshoes
New Coder

 
Join Date: Aug 2012
Location: France
Posts: 27
Thanks: 9
Thanked 0 Times in 0 Posts
oddshoes is an unknown quantity at this point
syntax error when using POST values in query

I am trying to build a query to check stock levels via a web page. I post the values through, print them just to check , then try to use them to build the query. The $_POST array is ok but the query fails and I get a syntax error
Code:
<?php
print_r($_POST);
      // 3. perfprm database query
	$result = mysql_query("SELECT SUM({$_POST[1]}) FROM `orders` WHERE `takenAt`= '{$_POST[0]}' and `collectDate` BETWEEN '{$_POST[2]}' AND '{$_POST[3]}' ", $connection );
	if (!$result)
{
	die("sorry can't do that one: " . mysql_error());
}
	// 4. use returned data      
print_r($result)

?>
I am still rather new to this and would greatly appreciate a hint or two

cheers
oddshoes is offline   Reply With Quote