Re: Lost in PHP (part 1) ---- Sequle to Lost in Query
| From: | John Holmes | Date: | Mon, 11 Oct 2004 17:19:40 +0000 |
| Subject: | Re: Lost in PHP (part 1) ---- Sequle to Lost in Query | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-199216@lists.php.net to get a copy of this message | ||
GH wrote:
Now I m perplexed time 10! I run the code that follows.... this time providing a query string of admin_template.php?api=101 I have an if statement that tests if $_GET['api'] == 0 .... if it is true I have it listing options, else it queries the database with that ID and loads the associated file.You have a lot more tests than that...
However it does not seem to execute the else....use var_dump($_GET['api']) and it may give you a clue. Your is_int() test is going to fail each time because anything passed through $_GET or $_POST is a string. FYI, you could essentially replace all of those tests you do on $_GET['api'] with if(empty($_GET['api'])) { echo 'bad value'; //or select everything from table ? } else { $input['api'] = (int)$_GET['api']; $query = "SELECT * FROM yourtable WHERE api = {$input['api']}"; ... } -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.comI: thought that the value may of been wrong so I used echo $_GET['api']; and it returned 101