RedInjection Posted November 6, 2015 Share Posted November 6, 2015 Hello, print $_GET['id']; If a users goes to page.php?id=X then it will show the value but how do I make it if a user goes page.php that it shows no error as it say's its not defined? Is there a simple way of doing it or do I need to write an IF function that sets id as nothing initially and if it has value then display? Quote Link to comment https://forums.phpfreaks.com/topic/299305-query-about-how-to-hide-errors-if/ Share on other sites More sharing options...
Solution Ch0cu3r Posted November 6, 2015 Solution Share Posted November 6, 2015 Before using $_GET['id'] you need to check it exists. One way is to use the ternary operator $id = isset($_GET['id']) ? $_GET['id']: '' /* <-- set this to the default value */; Quote Link to comment https://forums.phpfreaks.com/topic/299305-query-about-how-to-hide-errors-if/#findComment-1525801 Share on other sites More sharing options...
RedInjection Posted November 6, 2015 Author Share Posted November 6, 2015 Thanks for your quick help! Quote Link to comment https://forums.phpfreaks.com/topic/299305-query-about-how-to-hide-errors-if/#findComment-1525802 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.