Tuesday, December 31, 2013

[CodeIgniter][solved] Fatal error: Call to a member function row() on a non-object in xxx

For my case it's caused by wrong SQL.
Ci can not use the correct SQL to access database, and return an right object,
so that's why I use this sentence would call to a member function row() on a non-object ,

$query->row(0)->$photodbfield[1];

The problem is cause by the line highlighted:



Change that to correct SQL can run again:

        $sql      = 'SELECT * FROM p_photo AS p
                     LEFT JOIN p_index AS ind ON p.photo_id = ind.p_photo
                     WHERE ind.html_index = '.$html_index.'
                     LIMIT 1;';
To that : (added the quotion mark in red)

        $sql      = 'SELECT * FROM p_photo AS p
                     LEFT JOIN p_index AS ind ON p.photo_id = ind.p_photo
                     WHERE ind.html_index = "'.$html_index.'"
                     LIMIT 1;';
P.s.  So the solution is tried to look for the error in your SQL

No comments :

Post a Comment