TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 09-30-2008, 03:55 PM   #1 (permalink)
The Contributor
 
tego10122's Avatar
 
Join Date: Sep 2008
Location: Miami
Posts: 39
Thanks: 7
tego10122 is on a distinguished road
Default php join tables

I have the following code
PHP Code:
 $q mysql_query("SELECT * FROM `dom.user_comments`, `dom.members` WHERE `to` = '$user[username]' AND `username` = '$comment[author]' ORDER BY `user_comments.id` DESC LIMIT 3"); 
and always get->
Quote:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
Send a message via MSN to tego10122
tego10122 is offline  
Reply With Quote
Old 09-30-2008, 07:16 PM   #2 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

Have you run the query against the database to make sure it is correct? Echo that query out and copy & paste it into phpmyadmin or something like that. You might refer to a non-existent field into your query (mistype?).
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 09-30-2008, 08:56 PM   #3 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Your SQL query has errors where you write the table names. Anything in back-ticks (`) is taken literally so the query is read as though you're looking for tables literally named dom.user_comments and dom.members within the current database (assuming, dom). If you really must use back-ticks then a corrected query would be:
SELECT * FROM `dom`.`user_comments`, `dom`.`members` WHERE ...
Salathe is offline  
Reply With Quote
The Following User Says Thank You to Salathe For This Useful Post:
tego10122 (10-01-2008)
Old 10-06-2008, 06:59 PM   #4 (permalink)
The Contributor
 
tego10122's Avatar
 
Join Date: Sep 2008
Location: Miami
Posts: 39
Thanks: 7
tego10122 is on a distinguished road
Default

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in
__________________
You're Everyday Graphic Artist
Twitter|GigPark|Linked In
Send a message via MSN to tego10122
tego10122 is offline  
Reply With Quote
Old 10-06-2008, 08:12 PM   #5 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

grrrrrrrrrrrr
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 10-06-2008, 08:14 PM   #6 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

It means that whatever mysql_query returned was not a result resource, therefore it must have failed somewhere.
try:
PHP Code:
 mysql_query("your query") or die(mysql_error()); 
that wil give you a better idea what the problem might be
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Old 10-06-2008, 10:27 PM   #7 (permalink)
The Contributor
 
tego10122's Avatar
 
Join Date: Sep 2008
Location: Miami
Posts: 39
Thanks: 7
tego10122 is on a distinguished road
Default

got it working, :D.
__________________
You're Everyday Graphic Artist
Twitter|GigPark|Linked In
Send a message via MSN to tego10122
tego10122 is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 05:21 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design