Deivas Posted March 9, 2010 Share Posted March 9, 2010 How to find out if there is no $_GET method. At the moment I have an if statement: if($_GET['id']){ $link1 = mysql_connect("****","*****","*****"); mysql_select_db("*******", $link1); $result1 = mysql_query("SELECT * FROM servers WHERE id = $id", $link1); $num_rows1 = mysql_num_rows($result1); $data = mysql_query("SELECT * FROM servers WHERE id = $id") or die(mysql_error()); if($num_rows1 == 1){ while($info1 = mysql_fetch_array( $data )) { echo " <table border=\"1\"> <tr> <td><b>Name </a></td> <td>" .$info1['name'] ."</td> </tr> <tr> <td><b>Type </a></td> <td>" .$info1['type'] ."</td> </tr> <tr> <td><b>URL/IP: </b></td> <td>" .$info1['ip'] ."</td> </tr> <tr> <td><b>Port </b></td> <td>" .$info1['port']. "</td> </tr> <tr> <td><b>Description </b></td> <td>" .$info1['desc']. "</td> </tr> </table> <hr> <h4>Other information</h4> <table border=\"1\"> <tr> <td><b>Added by </b></td> <td>" .$info1['username']. "</td> </tr> <tr> <td><b>ID </b></td> <td>" .$info1['id']. "</td> </tr> <tr> <td><b>Date added (m/d/y) </b></td> <td>" .$info1['date']. "</td> </tr> </table> "; } } } What if statement should I do for normal stuff (just for index.php (not index.php?id=324234))? Link to comment https://forums.phpfreaks.com/topic/194681-_get/ Share on other sites More sharing options...
aeroswat Posted March 9, 2010 Share Posted March 9, 2010 Please explain. Show your code and tell us what's happening Link to comment https://forums.phpfreaks.com/topic/194681-_get/#findComment-1023821 Share on other sites More sharing options...
premiso Posted March 9, 2010 Share Posted March 9, 2010 Way to be descriptive! $_GET is not a method, but a Global Array which provides access to the query string of the url. If you are getting an "index not defined" error you can do this: $data = isset($_GET['data'])?$_GET['data']:''; Then when you access $data, it will not throw an error. If this is not the case, please provide us with something useful, such as the "unwanted" data you are receiving. Edit: Since you actually posted something useful. if (isset($_GET['id'])){ That will only execute if the array index of 'id' inside of $_GET has been set. Link to comment https://forums.phpfreaks.com/topic/194681-_get/#findComment-1023823 Share on other sites More sharing options...
Deivas Posted March 9, 2010 Author Share Posted March 9, 2010 Edited :} Link to comment https://forums.phpfreaks.com/topic/194681-_get/#findComment-1023825 Share on other sites More sharing options...
Deivas Posted March 9, 2010 Author Share Posted March 9, 2010 Thanks. Jeez, I love this forum. Link to comment https://forums.phpfreaks.com/topic/194681-_get/#findComment-1023830 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.