sakin Posted April 5, 2015 Share Posted April 5, 2015 Hi Larry,First I would like to express my satisfaction with your books,PHP book 4, and the advanced one covering OOP.I need your help here to figure out the way to solve this problem: The book: "Object Oriented PHP"(Fatal error: Call to a member function setFetchMode() on boolean)In fact the script stop working at the end of start of the form up to theand never run the query and the rest of the form.- the submit input is not shown in the browser.- I got the error notification by checking the view page source.That is all for now.Again, your books on PHP are great and the best among the ones I have ever read.thanks Link to comment Share on other sites More sharing options...
Antonio Conte Posted April 5, 2015 Share Posted April 5, 2015 This error occurs when you try to call a method on something that is not an object. In this case, the variable that should hold an object is actually a boolean. Make sure you actually create an object. An example can be the MySQLi functions.If you look at MySQLi::query(), the function returns either false (on error) or an object of the type mysql_result. A bad SQL query will make the query fail and the function to return false. The next call to $result->fetch_all(); would therefor return the error above. In you case, the error occurs when you try to call setFetchMode. It probably means your PDO query failed. Try something like this to reveal the error: $query = "..."; // Your current query $sth = $dbh->prepare($query); $sth->execute(); // Get error array $errors = $sth->errorInfo(); print_r($errors); Link to comment Share on other sites More sharing options...
Larry Posted April 6, 2015 Share Posted April 6, 2015 Thanks much for the nice words. I really appreciate it. Antonio's input is spot on. If you have any further problems with this, it'd really help to know the exact code or script you're using. Link to comment Share on other sites More sharing options...
sakin Posted April 7, 2015 Author Share Posted April 7, 2015 Thank you both Antonio and Larray. In fact there wasn't a mistake in Larry's original code, I was wondering! how come! I solved it by changing the computer and the topic for a while and returned to it again from the start. I learned much out of it. thanks Link to comment Share on other sites More sharing options...
Recommended Posts