View Full Version : [HELP] Facebook Like Button for MySQL Entries

06-14-2011, 12:51 PM
Hi guys. I am in a real pickle here. I am trying to make a website where;

- Anyone can leave a status
- Have the facebook like button on each status

However I cant seem to achieve this. I can get the like button under each status but as soon as one is clicked they are all clicked.

I hope someone can help.

Here is what I have:

@mysql_select_db($database) or die( "Unable to select database");
$status="SELECT * FROM comments WHERE 'id'";
if ($_GET['$status'] == "$id")

$query="SELECT * FROM comments";



echo "<b>Database Output</b><br><br>";

while ($i < $num) {


echo "<b>($id)</b> $comment<br>";

echo "<div class='fb_like'>
<fb:like width='340' layout='standard' show_faces='false' href='<?php the_permalink(); ?>' colorscheme='default'></fb:like>
</div> <br><hr>";


Where I have <?php the_permalink(); ?> I need it to somehow have its own url if that makes sense. So say localhost/post.php?id=1

06-14-2011, 04:01 PM
I think you have your answer already, just use a query string with the value of $id in it.

But I see much more wrong with your PHP script than the one thing you're asking about. For starters, your line 5 "if" statement's true block is not enclosed by squiggly brackets so by default it's only one statement long, the assignment of $query. But then you use that variable in the next statement so this is obviously not what you want to do.

And the value of $_GET['$status']? Probably not what you're thinking it should be.

And a nag: Whenever you call mysql_query(), you need to check the return value. FALSE means the query did not work, TRUE means it worked. This is a VERY IMPORTANT thing to check. You never want to assume a query just worked.

if (!$result)
die("Query Error! Query: $query<br>Error:".mysql_error());

06-14-2011, 04:11 PM
Sorry im new to PHP.
Im using $_GET['$status'] to try get the url post.php?status=1 so for the facebook like button in the href i would have something like post.php?status=$id

I also need it so that each status can have its own url somehow

Can you fix the code up so it does that or point me in the right direction before my head explodes :P