PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Jim_Bo
Forum Contributor
Posts: 390 Joined: Sat Oct 02, 2004 3:04 pm
Post
by Jim_Bo » Tue Mar 22, 2005 10:14 pm
Hi,
I am trying to check that a username exists before continung with the script .. With the code below it says invalid username .. when the name does exist in the database ..
Code: Select all
$sql_user_name_check = mysql_query("SELECT user_name FROM users WHERE user_name = '$user_name'");
$user_name_check = mysql_num_rows($sql_user_name_check);
if($user_name_check == 0)
{
echo "<b>Error</b>: Username doesn't exist .<p> <a href=\"../index.php?pages=compose\">BACK</a></p>";
return;
Im guesing its because username cant be set as user_name .. it must be username .. ?
The database field title is user_name ..
Thanks
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Mar 22, 2005 10:17 pm
echo out the query string.
Jim_Bo
Forum Contributor
Posts: 390 Joined: Sat Oct 02, 2004 3:04 pm
Post
by Jim_Bo » Tue Mar 22, 2005 10:27 pm
Hi,
?? not sure what you mean .. I had the same setup using alias instead of user_name and that seemed to work fine ..
Thanks
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Mar 22, 2005 10:33 pm
Code: Select all
echo "SELECT user_name FROM users WHERE user_name = '$user_name'";
Jim_Bo
Forum Contributor
Posts: 390 Joined: Sat Oct 02, 2004 3:04 pm
Post
by Jim_Bo » Tue Mar 22, 2005 11:00 pm
Hi,
Omg .. forget I asked .. so easy to miss simple things .. Missed one variable in a form
Thanks ..