Parse error: syntax error, unexpected 'public' (T_PUBLIC)

-1

Hello friends beasts in PHP, can anyone help me? I can not find the error in the following public function:

public function addLike($user_id, $tweet_id, $get_id){
        $stmt = $this->pdo->prepare("UPDATE 'tweets' SET 'likesCount' = 'likesCount' +1 WHERE 'tweetID' = :tweet_id");
        $stmt->bindParam(":tweet_id", $tweet_id, PDO::PARAM_INT);
        $stmt->execute();

        $this-> create('likes', array('likeBy' => $user_id, 'likeOn' => $tweet_id));
    }

If someone knows the error and can help, I thank you. Hugs to all.

    
asked by anonymous 19.05.2018 / 00:13

1 answer

1

The public should be used only in functions within classes (such as private and protected ), eg:

class Classe {
  public function addLike(){
     // código
  }
}

In your case, the function can not be declared as public . More about the subject you can consult the official documentation .

    
19.05.2018 / 00:21