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