gli Posted April 16, 2008 Share Posted April 16, 2008 if (($username != $usernamecheck ) && ( $email != $emailcheck )) { echo "registered" } what code for php is to check in mysql in users table for $username is it matching to any username value in all database table rows. sorry for my bad english. Quote Link to comment https://forums.phpfreaks.com/topic/101408-solved-problem-with-excact-value-matching-in-mysql/ Share on other sites More sharing options...
benphp Posted April 16, 2008 Share Posted April 16, 2008 <?php $sql = "SELECT username FROM users WHERE username = '$username' "; $result = mysql_query($sql) or trigger_error("SQL", E_USER_ERROR); while($row = mysql_fetch_row($result)) { $usernameCheck = $row[0]; if (($username == $usernamecheck)) { echo "registered" } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/101408-solved-problem-with-excact-value-matching-in-mysql/#findComment-518677 Share on other sites More sharing options...
wildteen88 Posted April 16, 2008 Share Posted April 16, 2008 You'd have to run a SQL Query against your database, exmaple: $qry = "SELECT * FROM your_table WHERE `username`='$username'"; $result = mysql_query($qry) or die('Query error:- ' . mysql_error()); // now to see if your query returned a match, you'd check to see the number of returned rows equals to one: if(mysql_num_rows($result) == 1) { echo '<b>'.$username.'</b> Exists!'; } else { echo '<b>'.$username.'</b> Does not exist!'; } Quote Link to comment https://forums.phpfreaks.com/topic/101408-solved-problem-with-excact-value-matching-in-mysql/#findComment-518680 Share on other sites More sharing options...
gli Posted April 16, 2008 Author Share Posted April 16, 2008 ok thnx Quote Link to comment https://forums.phpfreaks.com/topic/101408-solved-problem-with-excact-value-matching-in-mysql/#findComment-518741 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.