using LIKE to find a string value
| From: | Kyndig | Date: | Mon, 03 Jul 2000 15:16:07 +0000 |
| Subject: | using LIKE to find a string value | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-835@lists.php.net to get a copy of this message | ||
Greets list,
A newbie to the list, I am building a MySql backend links farm in PHP
at http://www.kyndig.com/listings ( feedback/general
insight appreciated )
My query is this. I have a value in a form field called: CheckName
I take that value, and run it through a check_name.php script to ensure that
the users name is not in my database already. ( We can only have 1 user
of the same name ) Let me show you the quick source, mayhap someone can
point out why it is continuosly returning a NOT FOUND value..even though
the name is in the database:
--this is the form code--
<!-- check for username already in database -->
<TR><TD bgcolor="#66CCFF" width="80%">
<form method=post action="http://kyndig.com/php-bin/listings/check_double.php?is_checking_name=1">
<font size="3" face="Lucida,Arial,Helvetica">
User Name: CHECK FOR AN AVAILABLE NAME FIRST!
</font>
</TD>
<TD width="20%" BGCOLOR="#66CCFF">
<input type="text" name="CheckName" size="15">
</TD></TR>
<TR><TD COLSPAN=2 align="center" BGCOLOR="#66CCFF">
<input type="Submit" value=" Quick Check "
name="is_checking_name=1">
</form>
</TD></TR>
<!-- end of username database check -->
--the check_doub.php code--
/* Is a user just checking for a similiar name in the database */
if ( $is_checking_name == "1" )
{
if ($CheckName == "" )
{
echo "<META HTTP-EQUIV=\"Refresh\" Content =
\"5; URL=".$html_url."/add.html\">";
echo "<HTML><BODY>";
echo "Entry was Empty, please enter a name before submitting
data.<br>";
echo "Click <a
href=\"$html_url/add.html\">here</a>";
echo "</BODY></HTML>";
die;
}
$query .= "SELECT username FROM users WHERE username LIKE
'$CheckName'";
$result = mysql_query($query,$db);
if($result != "0")
{
echo "$result<br>$CheckName<br>";
echo "<META HTTP-EQUIV=\"Refresh\" Content
= \"5; URL=".$html_url."/add.html\">";
echo "<HTML><BODY>";
echo "The Name: $CheckName was found, please choose
another name.<br>";
echo "Click <a
href=\"$html_url/add.html\">here</a>";
echo "</BODY></HTML>";
die;
}
if($result == "0")
{
echo "<META HTTP-EQUIV=\"Refresh\" Content
= \"5; URL=".$html_url."/add.html\">";
echo "<HTML><BODY>";
echo "The Name: $CheckName was NOT found, it is safe to
use this name.<br>";
echo "Click <a
href=\"$html_url/add.html\">here</a>";
echo "</BODY></HTML>";
die;
}
die;
}
Thankyou for any help,
Kyndig