mrooks1984 Posted October 20, 2011 Share Posted October 20, 2011 Hello all, i am hoping someone can help me. i have some code i have been working on and i am trying to add a 404 page if it cant find the page, i know it will be some sort of if statment, but with me been pretty much a noob at php i am stuck. heres the code that the page calls. function get_content() { //Get page name from browser if none call it home $page = (isset($_GET['page'])) ? $_GET['page'] : 'home'; //Get The Page Content $sql = "SELECT * FROM content WHERE page = '$page'"; $res = mysql_query($sql) or die (mysql_error()); while($row = mysql_fetch_assoc($res)){ //Show The Page Content echo '<h1>' . $row['title'] . '</h1>'; echo $row['body']; } } thanks all. Quote Link to comment https://forums.phpfreaks.com/topic/249445-php-404-isset-help/ Share on other sites More sharing options...
bh Posted October 20, 2011 Share Posted October 20, 2011 hi, heres an example: $sql = "SELECT * FROM content WHERE page = '$page'"; $res = mysql_query($sql) or die (mysql_error()); if (0 === mysql_num_rows($res)) { // page not found // send a header and exit } while($row = mysql_fetch_assoc($res)){ Quote Link to comment https://forums.phpfreaks.com/topic/249445-php-404-isset-help/#findComment-1280771 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.