pioneerx01 Posted December 21, 2010 Share Posted December 21, 2010 $query = "SELECT * FROM name_list WHERE Name= '$_POST[Name]' "; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ if ( ($row['Name']) == $_POST['Name'] ) echo "ERROR"; else echo "rest of the code"; } So this code compares (or it should) the name entered by the user in the form to the list of names already in database. If the user enters a name in the form that is in the database I get and "ERROR" as I should. But is they enter a name that is not in the database I am not getting "rest of the code." Why? Quote Link to comment https://forums.phpfreaks.com/topic/222333-having-trouble-with-this-simple-code/ Share on other sites More sharing options...
BlueSkyIS Posted December 21, 2010 Share Posted December 21, 2010 $query = "SELECT * FROM name_list WHERE Name= '{$_POST['Name']}' "; $result = mysql_query($query) or die(mysql_error()); if (mysql_numrows($result) > 0) { echo "ERROR"; } else { echo "rest of the code"; } Quote Link to comment https://forums.phpfreaks.com/topic/222333-having-trouble-with-this-simple-code/#findComment-1150046 Share on other sites More sharing options...
pioneerx01 Posted December 21, 2010 Author Share Posted December 21, 2010 cool, thanks a ton. See, beginner like me does not know stuff like that Quote Link to comment https://forums.phpfreaks.com/topic/222333-having-trouble-with-this-simple-code/#findComment-1150050 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.