Jump to content

Recommended Posts

ok so i was wondering if someone could help me?

 

this is what i want to do, click on a picture it add's it to a cookie

 

then on another page load that image and others that were added from the cookie and display them all at once

 

i made two pages

cookie_setup.php looks like this

<?
//load values from previous page
$design = $_GET['$id'];

//load values currently in cookie
$count = $_COOKIE['$count']; 
$designarray = $_COOKIE['designarray[$count]'];

//create new array variable
$count = $count + 1;

//set new values
$designarray['$count'] = $design;
//apply new values to cookie
setcookie('designarray[$count]','$design', time() +7200);
setcookie('count', '$count', time() +7200);
?>

 

and teh other page to display whats in the cookie

<html>
<body>
<table width="100%" border="1">
<?
$count = $_COOKIE['count']; 
$designarray = $_COOKIE['designarray[$count]'];
foreach ($designarray[$count])
{ 
echo " <tr> /n";
echo "<td>$design</td> /n";
echo "<td><img src='../images/cabinet_glass_lg_$design.jpg' height='100' alt='image'></td> /n";
echo "</tr> /n";
}

?>
</table>
</body>
</html>

 

when i try to open cookie_table

 

i get teh error message:

Parse error: syntax error, unexpected ')' in /folders*/cookie_table.php on line 7

 

*change actual file path for security reasons

 

hope you guys can help me, thanks ahead of time.

 

Link to comment
https://forums.phpfreaks.com/topic/118667-errors-with-foreach-command/
Share on other sites

thanks for the wickedfast reply dark water.

 

lol i did but i guess i though the

as $design was unessecary.

 

well i put it in, now i get Warning: Invalid argument supplied for foreach() in /folder/cookie_table.php on line 7

 

however below that i do get a thin line which i think is supposed to be my table, but nothing is in it.

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.