gathos Posted August 7, 2008 Share Posted August 7, 2008 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 More sharing options...
DarkWater Posted August 7, 2008 Share Posted August 7, 2008 Try: foreach ($designarray as $design) { >_> Read up on foreach syntax too. Link to comment https://forums.phpfreaks.com/topic/118667-errors-with-foreach-command/#findComment-610950 Share on other sites More sharing options...
gathos Posted August 7, 2008 Author Share Posted August 7, 2008 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. Link to comment https://forums.phpfreaks.com/topic/118667-errors-with-foreach-command/#findComment-610960 Share on other sites More sharing options...
DarkWater Posted August 7, 2008 Share Posted August 7, 2008 Then $designarray is not an array. Link to comment https://forums.phpfreaks.com/topic/118667-errors-with-foreach-command/#findComment-610963 Share on other sites More sharing options...
gathos Posted August 7, 2008 Author Share Posted August 7, 2008 ok thanks darkwater, i guess i'll just head back to the basics and start over, with more tutorials. as a side note, i applaude, how much you help the community, thank you very much. Link to comment https://forums.phpfreaks.com/topic/118667-errors-with-foreach-command/#findComment-610973 Share on other sites More sharing options...
DarkWater Posted August 7, 2008 Share Posted August 7, 2008 Heh, thanks. Link to comment https://forums.phpfreaks.com/topic/118667-errors-with-foreach-command/#findComment-610978 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.