Jump to content

[SOLVED] problem with excact value matching in mysql


gli

Recommended Posts

<?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" 
} 
}

?>

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!';
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.