0

Hi all, im sure this will be areally quick solution for you masters out there,

Im trying to create a SELECT query but I am continually getting a parse error ?

$query="SELECT * FROM friends WHERE (user_id = '$_SESSION[SESS_MEMBER_ID]' AND request_id = '$profile_id') OR (request_id = '$_SESSION[SESS_MEMBER_ID]' AND user_id = '$profile_id')";
$result = mysql_query($query);
$row = mysql_num_rows($result);

Hope someone can point me in the right direction as to where I am going wrong

4
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by diafol
0

@rozendaa hi, thanks for your input,

When I use single quotes i get the following error message

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\xampp\htdocs\www.website.com\members\addfriends.php on line 33

is it best to use INSERT INTO friends

or UPDATE friends SET

0

Sorry, to short an answer. The additional quotes were intended for php to proces. And for that to work you must use explicit concatenation.
The following should work.

$query="SELECT * FROM friends WHERE (user_id = '".$_SESSION['SESS_MEMBER_ID']."' AND request_id = '$profile_id') OR (request_id = '".$_SESSION['SESS_MEMBER_ID']."' AND user_id = '$profile_id')";
$result = mysql_query($query);
$row = mysql_num_rows($result);
0

Also give a try for this:

$query="SELECT * FROM friends WHERE (user_id = $_SESSION['SESS_MEMBER_ID'] AND request_id = $profile_id) OR (request_id = $_SESSION['SESS_MEMBER_ID'] AND user_id = $profile_id)";
0

When using array vars inside double quotes - brace {} them out:

$query="SELECT * FROM friends WHERE (user_id = '{$_SESSION['SESS_MEMBER_ID']}' AND request_id = '$profile_id') OR (request_id = '{$_SESSION['SESS_MEMBER_ID']}' AND user_id = '$profile_id')";
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.