Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2011
    Thanked 0 Times in 0 Posts

    Exclamation [HELP] Facebook Like Button for MySQL Entries

    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:

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

    $query="SELECT * FROM comments";



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

    while (
    $i $num) {


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

    "<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
    Last edited by FatDank; 06-14-2011 at 02:23 PM.

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Thanked 637 Times in 625 Posts
    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.
    PHP Code:
    if (!
    "Query Error! Query: $query<br>Error:".mysql_error());

  • #3
    New to the CF scene
    Join Date
    Jun 2011
    Thanked 0 Times in 0 Posts
    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
    Last edited by FatDank; 06-14-2011 at 04:17 PM.


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts