DaveLinger Posted September 15, 2006 Share Posted September 15, 2006 I'm getting both of these errors now that I've switched to a new server. The code it doesn't like is...[code]<?phpif($_GET['page'] == ''){$id="index";}else{$id = $_GET['page'];}?>[/code] Link to comment https://forums.phpfreaks.com/topic/20913-notice-undefined-index-and-notice-undefined-variable/ Share on other sites More sharing options...
onlyican Posted September 15, 2006 Share Posted September 15, 2006 That should workA little tip to make it cleaner$id = isset($_GET["page"]) ? $_GET["page"] : "index";try usin the isset(); Link to comment https://forums.phpfreaks.com/topic/20913-notice-undefined-index-and-notice-undefined-variable/#findComment-92636 Share on other sites More sharing options...
DaveLinger Posted September 15, 2006 Author Share Posted September 15, 2006 what about for something like this?[code]if($id == ''){$query="SELECT *, DATE_FORMAT(Date, '%W, %M %D %Y') AS my_date FROM wg_pages WHERE id=\"$id2\" ORDER BY datetime DESC";}else{$query="SELECT *, DATE_FORMAT(Date, '%W, %M %D %Y') AS my_date FROM wg_pages WHERE id=\"$id\" ORDER BY datetime DESC";}[/code] Link to comment https://forums.phpfreaks.com/topic/20913-notice-undefined-index-and-notice-undefined-variable/#findComment-92643 Share on other sites More sharing options...
Barand Posted September 15, 2006 Share Posted September 15, 2006 Depends on whether $id has previously been defined or not . Link to comment https://forums.phpfreaks.com/topic/20913-notice-undefined-index-and-notice-undefined-variable/#findComment-92646 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.