Jump to content

[SOLVED] SELECT query help


adamlacombe

Recommended Posts

I am trying to make it so if someone had added someone as a friend it will look something like this in the database:

id=1

from=admin

to=test

status=1

 

1 is its been excepted,

I have this:

<?php
$ff=mysql_query("SELECT * FROM friends WHERE `to`='{$row['username']}' AND `status`='1' OR from='{$row['username']}' LIMIT 0,10") or die(mysql_error());
if(mysql_num_rows($ff)>0){
echo "<div class='header'>Friends</div>";
echo "<div class='content'>";
while($friends=mysql_fetch_array($ff))
{
$ftname=$friends[to];
$ffname=$friends[from];

if($ffname){
  echo "<a href='index.php?action=profile&username=$ffname'>$ffname</a><br />";
}else{
  echo "<a href='index.php?action=profile&username=$ftname'>$ftname</a><br />";
} ///end if

}
echo "</div>";
}
?>
<br />

which is to pull that info, showing it on a users profile.

 

but keep getting this 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 'from='admin' LIMIT 0,10' at line 1

 

Any idea why?

Thanks!  8)

Link to comment
https://forums.phpfreaks.com/topic/168561-solved-select-query-help/
Share on other sites

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.