Thu. Jan 16th, 2020

Host your Website

Read and learn

Create a PHP Like Button

1 min read

28 thoughts on “Create a PHP Like Button

  1. Help
    Notice: Trying to get property 'likes' of non-object

    what could be wrong here?

    on echo '<pre>', print_r($articles, true) ,'</pre>';
    Array

    (
    [0] => stdClass Object

    (

    [entryID] => 1

    [title] => First Post

    [likectr] => 0

    )
    )

    please help.

  2. My code is not working…its allowing d same user to like d same post multiple times..i hv also checked it inserts multiple records in d DB for when the same user likes d same post…how do i correct this?
    please help…
    thanks

  3. Hi! Good tutorial!

    I have just one question… I don't know why when i put this line of code "$row->liked_by = $row->liked_by ? explode('|', $row->liked_by) : [];" the whole program stop working, it sends me the next error message "Parse error: syntax error, unexpected '[' in /home/canifarm/public_html/Noticias/Principal/Likes/index.php on line 24"

    I've looked for that error but i can´t find the answer, could you help me?

  4. question – in your insert into articles_likes code (in like.php), how would you structure the INSERT statement if you had more variables to save? I want to save the date and time. After LIMIT 1 I added a comma and NOW() to get the date/time but it doesn't add the vote or date/time. If I remove it then it works.

  5. what if i want the user not to be assigned? 

    $_SESSION['user_id'] = (int)1;

    what i mean is if i have a login page and i want the userd id of the logged in person to be the one being processed instead of the (int)1?? HELP PLEASE

  6. I've got a problem using the SQL statement in like.php with PDO (prepare() and bindValue()). Could you give any advice on this? Do these {brackets} play any role in the SELECT statement?

  7. Thanks Alex , it works for me .
    Can you please create another video for an unlike method if an user wants to unlike an article if he changes his mind or does`nt like it any more ? 
    And it will be perfect to have a max limit of displayed users that liked an article 

  8. if anybody wants to correct the grammar, just replace where you have 'people' in the sentence with the following code;
    <?php 
    if($article->article_likes < 2){
    echo 'person';
    }else{
    echo 'people';
    }
    ?>

Comments are closed.

Copyright © All rights reserved. | Newsphere by AF themes.