How to check whether a mysql select statement result has a value or not in php?

Posted by udaya on Stack Overflow See other posts from Stack Overflow or by udaya
Published on 2010-05-08T11:16:46Z Indexed on 2010/05/08 11:18 UTC
Read the original article Hit count: 193

Filed under:
|
|
|
|

I have a textbox UserName and a Check Availability button next to it..... I have checked the availability by passing UserName textbox value..... But it doesn't seem to work....

Here is what i am doing?

echo $UserName = $_GET['CheckUsername'];
$_SESSION['state'] = $State;
$queryres = "SELECT dUser_name FROM tbl_login WHERE dUser_name='$UserName'";
$result = mysql_query($queryres,$cn) or die("Selection Query Failed !!!");

if($result==true) // this condition doesn't seem to work
    {
       echo "User Name Available";
    }
else
{
        echo "Sorry user name taken";
}

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql