Jump to content

Help with simple if statement and the use of && (AND)


colleyboy

Recommended Posts

Hi I am having trouble getting the parser to parse this statement:

if (($row['liked_user_id']==$user_id)&&($row['user_id']==$the_user_id)){
echo "<FONT SIZE=1 COLOR=BLUE>You Like This Artist";
}

 

It spits out:

 

Parse error: syntax error, unexpected T_ELSE in /home/wormste1/public_html/tilburywebdesign/shop/FTPServers/boomchoon/pages/profileabout.php on line 84

 

I am trying to combine two clauses where the "liked_user_id" row is equal to the variable "$user_id" AND the row "user_id" equals the variable "$the_user_id".

 

Many Thanks!

 

I forgot an } lol!

 

I have another problem though:

 

$aretheyliked = mysql_query("SELECT * FROM boom_likes WHERE user_id=$the_user_id");

while($row = mysql_fetch_array($aretheyliked))

 

It turns around and says "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/wormste1/public_html/tilburywebdesign/shop/FTPServers/boomchoon/pages/profileabout.php on line 73

"

 

Line 73 is:    while($row = mysql_fetch_array($aretheyliked))

 

Dont get it :S

That means the query failed and returned FALSE instead of a resource. You will need to display the query error with something like:

$query = "SELECT * FROM boom_likes WHERE user_id=$the_user_id";

$result = mysql_query($query) or die("Query failed!<br />Query: $query<br />Error: " . mysql_error());

 

On a side note - if $the_user_id is not an integer it needs to be wrapped in quotes. WHERE user_id='$the_user_id'

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.