helraizer Posted June 2, 2008 Share Posted June 2, 2008 Hey folks, I have made an image-based shoutbox and now users can view older and newer message on the shoutbox depending on the $_GET['page'] - pagination - that works. However, since it's image based and can be linked in forums etc. on the Internet I only want it to save the gif image if $page == 1, so the newest shouts are saved onto the image. Yet the users can still view the other messages on site without it changing the saved gif image. What I've tried so far is this: <?php if (isset($_GET['page']) && is_numeric($_GET['page'])) { $page = mysql_real_escape_string(htmlspecialchars($_GET['page'])); } else { $page = 1; } //other code - not relevant for this purpose if ($page == 1) { imagegif($image); // paint the image in browser imagegif($image, "user/" . $user . ".gif"); //export as gif file } elseif(!isset($filter) && $page == 1) { imagegif($image); // paint the image in browser imagegif($image, "user/" . $user . ".gif"); //export as gif file } elseif($page != 1) { imagegif($image); // paint the image in browser } elseif(isset($filter)) { imagegif($image); // paint the image in browser } else { } ?> Which, to me means that when $page == 1 then it loads the image in the browser and also saves user/helraizer.gif and if $page != 1 then it only loads it to the browser and doesn't save the gif. But even if $page == 3 then it saves that as the image and therefore the image hosted on a forum will keep changing as each user views a different thing. I know that $page works because it changes the contents of the image, but it doesn't work within the if statement. Can you see what's/if anything's wrong with the code? Would a switch statement be a better solution? Thanks, Sam Link to comment https://forums.phpfreaks.com/topic/108382-solved-pagination-within-image-imagegif-problem/ Share on other sites More sharing options...
BlueSkyIS Posted June 2, 2008 Share Posted June 2, 2008 this will never happen, because at this point we already know $page != 1: } elseif(!isset($filter) && $page == 1) { imagegif($image); // paint the image in browser imagegif($image, "user/" . $user . ".gif"); //export as gif file should be more like: if ($page == 1) { imagegif($image); // paint the image in browser imagegif($image, "user/" . $user . ".gif"); //export as gif file } elseif(isset($filter)) { imagegif($image); // paint the image in browser } else { // Here, $page != 1 && !isset($filter) imagegif($image); // paint the image in browser } Link to comment https://forums.phpfreaks.com/topic/108382-solved-pagination-within-image-imagegif-problem/#findComment-555691 Share on other sites More sharing options...
helraizer Posted June 2, 2008 Author Share Posted June 2, 2008 this will never happen, because at this point we already know $page != 1: } elseif(!isset($filter) && $page == 1) { imagegif($image); // paint the image in browser imagegif($image, "user/" . $user . ".gif"); //export as gif file should be more like: if ($page == 1) { imagegif($image); // paint the image in browser imagegif($image, "user/" . $user . ".gif"); //export as gif file } elseif(isset($filter)) { imagegif($image); // paint the image in browser } else { // Here, $page != 1 && !isset($filter) imagegif($image); // paint the image in browser } Ah, thank you! had to change it slightly but it works now. =D if (isset($filter)) { imagegif($image); // paint the image in browser } elseif ($page == 1) { imagegif($image); // paint the image in browser imagegif($image, "user/" . $user . ".gif"); //export as gif file } else { // Here, $page != 1 && !isset($filter) imagegif($image); // paint the image in browser } Sam Link to comment https://forums.phpfreaks.com/topic/108382-solved-pagination-within-image-imagegif-problem/#findComment-555720 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.