PDA

View Full Version : Cannot set friend-based options


Hall of Famer
04-02-2012, 04:16 PM
The error message 'Call to a member function fetchObject() on a non-object' is displayed when users try to set friend-based options
As was reported from Tale of Dragon forums, the current Mys v1.3.0 release has a glitch with the friends.php file. This error is generated when users attempt to set friend-based options:

Fatal error: Call to a member function fetchObject() on a non-object in /home/taleofdr/public_html/friends.php on line 115After taking a look into the friends.php, I found that the keyword 'AND' was missing from the query that retrieves database information for friends. This is not a problem for Mys v1.3.1 as the new database class' methods join() and select() takes care of sql queries. But now you see, it is a good idea to implement a database class in a way that it prevents errors in database queries.

Hall of Famer
04-02-2012, 04:18 PM
To fix this, find the long query string from friends.php file:


$query = "SELECT * FROM {$prefix}users, {$prefix}users_options
WHERE {$prefix}users.username='{$loggedinname}'
{$prefix}users_options.uid = {$prefix}users.uid
{$prefix}users_options.username = {$prefix}users.username";


And replace with:


$query = "SELECT * FROM {$prefix}users, {$prefix}users_options
WHERE {$prefix}users.username='{$loggedinname}'
AND {$prefix}users_options.uid = {$prefix}users.uid
AND {$prefix}users_options.username = {$prefix}users.username";


With the keyword 'AND' in the query, the PDO statement object should be successfully generated, thereby fixing the error.