shocker-z Posted October 22, 2007 Share Posted October 22, 2007 hi im having an issue ive never come across before.. OS: Windows 2003 Server Webserver: IIS 6 PHP: 5.2.4 MySQL: 5.0 if i have this code at the top of my page then i get "HTTP 500 Internal Server Error" but remove it and it works fine cept im getting, call to undifined function mysql_connect() which ive followed about 5 guides to fix and was unable to resolve so help on that would be appreciated too. <?php if (!$_GET['page']) { header("location: index.php?page=home"); } else { $page=$_GET['page'].'.php'; include('connect.php'); } ?> regards Liam Link to comment https://forums.phpfreaks.com/topic/74318-error-500-when-if-_getpage-at-top-of-page/ Share on other sites More sharing options...
only one Posted October 22, 2007 Share Posted October 22, 2007 Try: <?php if ($_GET['page'] == NULL) { header("location: index.php?page=home"); } else { $page=$_GET['page'].'.php'; include('connect.php'); } ?> or: <?php if (!$_SERVER['QUERY_STRING']) { header("location: index.php?page=home"); } else { $page=$_GET['page'].'.php'; include('connect.php'); } ?> Link to comment https://forums.phpfreaks.com/topic/74318-error-500-when-if-_getpage-at-top-of-page/#findComment-375484 Share on other sites More sharing options...
Wes1890 Posted October 22, 2007 Share Posted October 22, 2007 Or also this should work: <?php if ( !isset($_GET['page']) ) { header("location: index.php?page=home"); } else { $page=$_GET['page'].'.php'; include('connect.php'); } ?> Link to comment https://forums.phpfreaks.com/topic/74318-error-500-when-if-_getpage-at-top-of-page/#findComment-375578 Share on other sites More sharing options...
only one Posted October 22, 2007 Share Posted October 22, 2007 Could i also advise something, by simply doing this: $page=$_GET['page'].'.php'; include('connect.php'); Your are really leavaing yourself open, I'd advise setting a file_exists() function in there.. <?php if ( !isset($_GET['page']) ) { header("location: index.php?page=home"); } else { $page = $_GET['page'].'.php'; if(file_exists($page) { include('connect.php'); } else { echo "404"; } } ?> Link to comment https://forums.phpfreaks.com/topic/74318-error-500-when-if-_getpage-at-top-of-page/#findComment-375608 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.