This question already has an answer here:
How would I go about trying to check if a certain value exists in a mysql set? I have this code:
that I was experimenting with (I doubted it would work) And it's throwing this error:
$result = mysql_query("SELECT * FROM posts ORDER BY time DESC");
while ($row = mysql_fetch_array($result)) {
$result1 = mysql_query("SELECT * FROM friends WHERE friends = $row{'name'}");
$row1 = mysql_fetch_array($result1);
if ($row == 1) {
echo "<b style='color: #D55292;'>".$row{'name'}."</b> says <br>".$row{'cont'}."<br><b style='color: #A1A1A1';>Posted on ".$row{'time'}."</b><br><br>";
}
}
I'm getting these errors:
Notice: Array to string conversion in C:\xampp\htdocs\index.php on line 44
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\index.php on line 45
Notice: Array to string conversion in C:\xampp\htdocs\index.php on line 44
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\index.php on line 45
Notice: Array to string conversion in C:\xampp\htdocs\index.php on line 44
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\index.php on line 45
Could you guys give me a few pointers on how I would go about doing this? Thanks in advanced!
I just thought the question might not be clear enough:
I have a set that stores all your "friends" in my "friends" table. I also have a table that stores all the "posts" with the values of your name, the content, the time, and who can view it. I'm trying to get those posts (Which I have done successfully), and print them. I can do that. I just want to make it so you can only see posts where the "name" value is equal to a string in your "friends" set.
</div>