TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   php join tables (http://www.talkphp.com/general/3398-php-join-tables.html)

tego10122 09-30-2008 03:55 PM

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

xenon 09-30-2008 07:16 PM

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?).

Salathe 09-30-2008 08:56 PM

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 ...

tego10122 10-06-2008 06:59 PM

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in

sketchMedia 10-06-2008 08:12 PM

grrrrrrrrrrrr

sketchMedia 10-06-2008 08:14 PM

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

tego10122 10-06-2008 10:27 PM

got it working, :D.


All times are GMT. The time now is 08:47 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0