2

Newbie here, trying to get this to work: I am making an online index for a library. I am using php and mySQL which I am running on an apache server. I have created a class called book which contains information about each book, and a static class called DBFunctions which contains only static functions that I call to connect and interact with the database. I'm trying to call a function from the DBFunctions class from inside the Book class but I keep getting an error. My function within the book class is:

function setTagIDs(){
   this->TagIDs = DbFunctions::getTagIdsForBook($this->BookID);
}

the dbFunction creates a select statement connects to the database and returns the result. It works fine on a test page.

But when I call it from within the class I get the following error:

Parse error: syntax error, unexpected T_OBJECT_OPERATOR in \Classes\ClassBook.php on line 111

I've looked in quite a few places but I can't figure out what the problem is, any help would be much appreciated

Thanks

Steven

0

1 Answer 1

3

You are simply missing a $ on this:

  $this->TagIDs = DbFunctions::getTagIdsForBook($this->BookID);
  ^^

unexpected T_OBJECT_OPERATOR indicates a -> was encountered before it should have been there. So to interpret the error, find the first -> and look backwards.

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

1 Comment

@user985331 Don't. You're a self-proclaimed n00b and you'll get used to how PHP reports parse errors. If you don't have one, get a text editor that supports syntax highlighting. A missing $ might become immediately obvious with syntax highlighting, depending on the editor.

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.