0

Having some trouble with PHP static functions in my program. My code is below and I keep getting the error "Anonymous function expected". I'm using the IDE PhpStorm.

I've had a google but nothing comes up. If I remove the name of the function the error goes away but I don't know how to then call the function.

<?php

/**
 * @param mysqli $conn Connection to the database.
 * @param int $id The ID of the white card that is to be voted up.
 */
public static function voteUp($conn, $id){
    mysqli_query($conn, 'UPDATE WhiteCards SET Ups = Ups + 1 WHERE ID = ' . $id);
}

/**
 * @param mysqli $conn Connection to the database.
 * @param int $id The ID of the white card that is to be voted down.
 */
public static function voteDown($conn, $id){
    mysqli_query($conn, 'UPDATE WhiteCards SET Ups = Ups - 1 WHERE ID = ' . $id);
}
8
  • 2
    how you call these function .? Commented Feb 12, 2017 at 19:46
  • @scaisEdge OP: "but I don't know how to then call the function" ;-) so it's anyone's guess. Commented Feb 12, 2017 at 19:46
  • @Fred-ii- thanks .. I had not read properly .. but what for If "I remove the name of the function the error goes away " Commented Feb 12, 2017 at 19:47
  • 3
    public suggests the use of a class; you also want to know how to call the functions; this question is both unclear and too broad. Best you go back to reading all the relevant manuals. Commented Feb 12, 2017 at 19:48
  • @scaisEdge again; anybody's guess, too many unknowns as per ^ Commented Feb 12, 2017 at 19:50

1 Answer 1

3

Just solved it, the two functions needed to be in a class.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.