I'm trying to create a simple receipt for a transaction using data customer posted. All I'm getting is Parse error: syntax error, unexpected '"', expecting T_STRING or T_VARIABLE or T_NUM_STRING:
function receipt($transaction, $count, $product, $price, $date)
{
echo "You $transaction $count of $product at $price on $date";
}
receipt ('BOUGHT', "$_POST["itemcount"]", "$_POST["code"]", "$details["price"]", date("F j Y"));
I've tried adding curly braces/replacing quotes with braces, but neither approach worked.
Its working.
function receipt($transaction, $count, $product, $price, $date) { echo "You $transaction $count of $product at $price on $date"; }
receipt ('BOUGHT', $_POST["itemcount"], $_POST["code"], $details["price"], date("F j Y"));
You're trying to pass variables as strings, remove the quotes around them:
receipt ('BOUGHT', $_POST["itemcount"], $_POST["code"], $details["price"], date("F j Y"));
try below
receipt ('BOUGHT', $_POST['itemcount'], $_POST['code'], $details['price'], date("F j Y"));
instead of
receipt ('BOUGHT', "$_POST["itemcount"]", "$_POST["code"]", "$details["price"]", date("F j Y"));
function receipt($transaction, $count, $product, $price, $date)
{
echo "You ".$transaction." ".$count." of ".$product." at ".$price." on ".$date."";
}
receipt ('BOUGHT', $_POST['itemcount'], $_POST['code'], $details['price'], date("F j Y"));
You can also use this way to display your variables
Removed the double quotes, it's working now, thanks. Always thought I needed them, string or otherwise, apparently not.