ainoy31 Posted July 12, 2008 Share Posted July 12, 2008 Hello- I am trying to pass a few variables via the url. Here is my script: echo '<a href="'.$_SERVER['PHP_SELF'].'?pageNum=$nextPage&mode=Search&type=$Type">NEXT</a>'; echo '<a href="'.$_SERVER['PHP_SELF'].'?pageNum=$lastPage&mode=Search&type=$Type">LAST</a>'; The problem is that the value for $nextPage/$lastPage should be numeric and $Type should be a text. I realized this when I try to do a $_GET call and they are empty. Also, I can see it as empty when I put my mosue over the link as well. I am doing something wrong here. I have been coding since 6am today. Thanks. AM Link to comment https://forums.phpfreaks.com/topic/114457-solved-passing-variable-via-url/ Share on other sites More sharing options...
LooieENG Posted July 12, 2008 Share Posted July 12, 2008 <?php echo '<a href="' . $_SERVER['PHP_SELF'] . '?pageNum=' . $nextPage . '&mode=Search&type=' . $Type . '">NEXT</a>'; echo '<a href="' . $_SERVER['PHP_SELF'] . '?pageNum=' . $lastPage . '&mode=Search&type=' . $Type . '">LAST</a>'; ?> Link to comment https://forums.phpfreaks.com/topic/114457-solved-passing-variable-via-url/#findComment-588539 Share on other sites More sharing options...
teynon Posted July 12, 2008 Share Posted July 12, 2008 You can't have variables in a string that has single quotes. You have to either end the string and add the variable like LooieEng did, or use double quotes. You should also use urlencode on your variables to ensure it won't have any characters that mess up the variable list. urlencode(variable); Link to comment https://forums.phpfreaks.com/topic/114457-solved-passing-variable-via-url/#findComment-588541 Share on other sites More sharing options...
ainoy31 Posted July 12, 2008 Author Share Posted July 12, 2008 Thanks man. That solved my issue. Much appreciation. Link to comment https://forums.phpfreaks.com/topic/114457-solved-passing-variable-via-url/#findComment-588611 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.