views:

34

answers:

2
+2  Q: 

MySQL query error.

Can someone help me correct the following error I keep getting when trying to run my MySQL query.

Here is my error.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE user_id = '3' AND id = '3' AND friendship_status = '0'' at line 2

Here is my mysql code.

SELECT users_friends.*
WHERE user_id = '$user_id'
AND id = '$request_id'
AND friendship_status = '0'
+4  A: 

Probably need to add: FROM users_friends just before the WHERE.

SELECT  users_friends.*
FROM    users_friends
WHERE   user_id = '$user_id'
AND     id = '$request_id'
AND     friendship_status = '0'
Brock Adams
+3  A: 

Try this

(PHP assumed)

 $string = "SELECT from  database_name.table_name 
            WHERE user_id ='".$user_id."' AND id= '".$request_id."'
            AND friendship status ='0' ";

I have assumed that $user_id and $request_id are of varchar/text type

Prasoon Saurav