lilwing Posted July 17, 2008 Share Posted July 17, 2008 I am using $_GET values to create dynamic links. The variable is called $pageid. Obviously, when a user types the URL into his/her browser, the $_GET value is not set. In order to display the content on the homepage, I need $pageid = 'home' How can I set up a default value for $pageid? <?php $pageid= $_GET['pageid']; $query = mysql_query("SELECT Content FROM sfiscontent WHERE ContentID='$pageid'") or die(mysql_error()); while($row = mysql_fetch_array($query)) { $current = $row['Content']; echo $current; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/115309-solved-default-_get-value/ Share on other sites More sharing options...
GingerRobot Posted July 17, 2008 Share Posted July 17, 2008 isset() is your friend. You also wouldn't want to be querying the database without validating your input. if(isset($_GET['pageid'])){ $pageid = mysql_real_escape_string($_GET['pageid']);//ought to be sanitizing your input. }else{ $pageid = 'home'; } Quote Link to comment https://forums.phpfreaks.com/topic/115309-solved-default-_get-value/#findComment-592812 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.