hhex50 Posted August 7, 2009 Share Posted August 7, 2009 hi every1 i m new to php.....i ve been trying to figure out whats wrong with the code i wrote...its page counter....it works fine apart frm this that i am not able to display number of counts where i want them to b....infact im not able to display the right value at the right place....here it is... <?php session_register('v1'); session_register('v2'); session_register('v3'); ?> <?php echo "<html><head><title>webpage counter</title></head><body>"; if(isset($_GET['whpage'])){ echo "<b>You are on page".$_GET['whpage']."<b><br><br>"; $_SESSION["v".$_GET['whpage']]++; echo "No of visits ".$_SESSION["v".$_GET['whpage']]."<br>"; this line displays count perfectly fine } for($i=1;$i<=4;$i++){ if(isset($_GET['whpage'])==$i){ echo "<b><a href=\sesio.php?".session_id()."&whpage=$i\">Page $i</a></b>"; } else{ echo "<a href=\sesio.php?".session_id()."&whpage=$i\">Page $i</a>"; } echo ", which you have chosen ".$_SESSION["v".$i]." times.<BR>\n";here the number of counts are not being displayed i want them to be here echo $_SESSION['v1'];i wrote this line just for testing but it isnt displaying anything } //session_destroy(); echo "<br><br>"; echo "</body></html>"; ?> any help wud really be appreciated Link to comment https://forums.phpfreaks.com/topic/169261-not-being-able-to-display-sessions-properly/ Share on other sites More sharing options...
wildteen88 Posted August 7, 2009 Share Posted August 7, 2009 Few problems I see. session_register should not be used, it is depreciated. Remove it completely from your code. The main problem I see is you're not calling [m]session_start[/b]. This must be called at the top of your script whenever you are using sessions. Link to comment https://forums.phpfreaks.com/topic/169261-not-being-able-to-display-sessions-properly/#findComment-893175 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.