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. 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" } } ?> 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!'; } 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 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
Archived
This topic is now archived and is closed to further replies.