Code Comments
Programming Forum and web based access to our favorite programming groups.I need to check for username in 2 tables (user_basic and user_temp)
before I can alow incoming user to register new username, well, here is
what I had before I'w created temporary table:
$uname_check = mysql_query("SELECT uname FROM user_basic Where
(uname='$uname')");
if (mysql_num_rows($uname_check) > 0) { ...
but now, that mysql_num_rows isn't "working"...
now I have this lines:
$uname_check = mysql_query("SELECT uname.user_basic,uname.user_temp FROM
user_basic,user_temp Where (uname='$uname')");
if (mysql_num_rows($uname_check) > 0) { ...
and I'm geting this worning and my script fails in checking:
"mysql_num_rows(): supplied argument is not a valid MySQL result
resource in..."
can anyone help me?
--
Jan ko?
http://fotozine.org
--
Post Follow-up to this message
Jan:
You should check for errors after mysql_query(). That way you would see
that MYSQL is complaining about the syntax of your query.
Make two separate queries, one for user_basic and one for user_temp,
and add the number of rows returned from each query:
$uname_check1 =
mysql_query("SELECT uname FROM user_basic Where (uname='$uname')");
$uname_count1 = mysql_num_rows($uname_check);
$uname_check2 =
mysql_query("SELECT uname FROM user_temp Where (uname='$uname')");
$uname_count2 = mysql_num_rows($uname_check2);
if ($uname_count1 + $uname_count2 ) > 0) { ...
---
Steve
Post Follow-up to this message> SELECT uname.user_basic,uname.user_temp FROM > user_basic,user_temp Where (uname='$uname') should be: SELECT uname FROM user_basic WHERE uname='$uname' UNION SELECT uname FROM user_temp WHERE uname='$uname' Hilarion
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.