Jump to content

Shopping Cart Checkout?


Flezria

Recommended Posts

Hi guys!

 

I'm new here, and i have a quick question:

 

I'm building a shopping cart, for a website, everything works fine, but i have a problem when i wanna do the checkout:

 

The checkout is supposed to take all the products from the basket, and add them into an email, which will be sent to order-guy.

 

Those lines:

 

 

$message="Navn: $name \nTelefon nummer: $phone \nGruppe nummer: $grpnr \nAfdeling: $afdeling \n\n " .
foreach ($_SESSION['contents'] as $_SESSION['id']=>$_SESSION['qty']) {
$sql = "SELECT * FROM entries WHERE id = '$_SESSION[id]'";
$result = mysql_query($sql);
$row = mysql_fetch_row($result);
"Produktnavn: $row[1]\n
IRIS: $row[6]\n";
}

 

Gives me the error: syntax error, unexpected T_FOREACH

 

Anyone can help me with this?

 

Thanks!

Link to comment
Share on other sites

You have to end the first line or add some more code...

 

$message="Navn: $name \nTelefon nummer: $phone \nGruppe nummer: $grpnr \nAfdeling: $afdeling \n\n " ;
foreach ($_SESSION['contents'] as $_SESSION['id']=>$_SESSION['qty']) {
$sql = "SELECT * FROM entries WHERE id = '$_SESSION[id]'";
$result = mysql_query($sql);
$row = mysql_fetch_row($result);
"Produktnavn: $row[1]\n
IRIS: $row[6]\n";
}

Link to comment
Share on other sites

You can only concatenate values - literal strings, variables/properties, constants, return values from functions/methods, expressions...

 

You would need to concatenate the new information you are retrieving inside of the loop onto the end of the $message string.

 

Also, you should not be executing a query inside of a loop. You should get an array of the id values, concatenate those ids into a list and execuiting ONE query using an IN() comparison - http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_in You would then loop over the result set from that one query.

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.