Forum Moderators: coopster

Message Too Old, No Replies

mysql_fetch_assoc question

using array with multiple tables

         

lmanges

2:29 am on Mar 29, 2004 (gmt 0)



Newbie - Hi and thanks in advance!

Code in question:

$sql = "SELECT * FROM current_members, search_level, search_types, contract_style, members_specialties WHERE item == '$item' AND username = '$username'";

$rec = mysql_query($sql);
while($row = mysql_fetch_assoc($rec))

When I use only one table this works fine. As soon as I add the other tables it errors:
mysql_fetch_row(): supplied argument is not a valid MySQL result resource

I am trying to post information about all members to a Web page from multiple tables. $item and $username are the same in each table for each member. Should this work or am I way off?

Thanks

coopster

3:55 am on Mar 29, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, lmanges!

This means that your query is failing and my guess is that your statement is using a column name that is ambiguous,

item
and
username
are columns that exist in all of your tables. If you fully qualify the column names with your primary table name, your query should execute as desired.

$sql = "SELECT * FROM current_members, search_level, search_types, contract_style, members_specialties WHERE current_members.item = '$item' AND current_members.username = '$username'";