crawlerbasher Posted May 15, 2010 Share Posted May 15, 2010 $email = strip_tags($_GET['e']); if (is_numeric ($email)) { echo "True"; } else { echo "False"; } This is a peace of code that I'm working with. Now I know how to connect to database and that. But the one thing that I've no idea on how to do is this. Checking the number stored in the Variable and comparing that with the id stored in the database. An example. $email = 1 Database has an id that contains 1 $email = 43 Database has an id that contains 43 $email = 54 Database has no id that contains 54 and so the script is not executed. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted May 15, 2010 Share Posted May 15, 2010 $query = "SELECT db_field FROM db_table WHERE db_field = $email LIMIT 1"; $result = mysql_query( $query ); $num = mysql_num_rows($result) if( $num > 0 ) { // Record exists, so do something } else { // Record doesn't exist, so do something else } Quote Link to comment Share on other sites More sharing options...
crawlerbasher Posted May 15, 2010 Author Share Posted May 15, 2010 Thank you. I was looking at something like this to find if the variable existed or not. But was not working. But your code was shorter and cleaner and worked. Thank you. Quote Link to comment 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.