Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

newbie: 2 tables as 1 result to count... how to?
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
--

Report this thread to moderator Post Follow-up to this message
Old Post
JaNE
11-18-04 08:57 PM


Re: newbie: 2 tables as 1 result to count... how to?
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


Report this thread to moderator Post Follow-up to this message
Old Post
Steve
11-19-04 01:57 PM


Re: newbie: 2 tables as 1 result to count... how to?
> 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



Report this thread to moderator Post Follow-up to this message
Old Post
Hilarion
11-19-04 01:57 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP SQL archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:57 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.