CodeIgniter Forums
Fatal error: Call to a member function row() on a non-object - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Fatal error: Call to a member function row() on a non-object (/showthread.php?tid=2813)



Fatal error: Call to a member function row() on a non-object - El Forum - 08-25-2007

[eluser]BrandonDurham[/eluser]
Why would this be happening here?
Code:
$sql = "UPDATE prizes SET
    email                 = '$email',
    fname                = '$first_name',
    lname                = '$last_name',
    address1            = '$address',
    address2             = '$add_address',
    city                 = '$city',
    state                 = '$state',
    zip                  = '$zip',
    date_submitted      = '$date_submitted',
    opt_in                 = '$opt_in',
    company             = '$company',
    day_phone            = '$day_phone',
    evening_phone        = '$evening_phone'
    WHERE id            = '8'
";

$query = $this->db->query($sql);
$row = $query->row();
Here's the full error:
Quote:Fatal error: Call to a member function row() on a non-object in /Users/Deefee/Documents/Sites/073MHG232/system/application/models/db_functions.php on line 88
Line 88 is $row = $query->row();.


Fatal error: Call to a member function row() on a non-object - El Forum - 08-25-2007

[eluser]BrandonDurham[/eluser]
Here's the query it's spitting out:
Code:
UPDATE prizes SET email = '[email protected]', fname = 'Brandon', lname = 'Durham', address1 = '5300 Bee Caves Road', address2 = '17305 E Darleen', city = 'Austin', state = 'AK', zip = '78745', date_submitted = '2007-08-25 18:35:26', opt_in = 'Yes', company = 'Kolar Advertising', day_phone = '(123) 123-1231', evening_phone = '(555) 555-5555' WHERE id = '8'



Fatal error: Call to a member function row() on a non-object - El Forum - 08-25-2007

[eluser]NemetraL[/eluser]
Any issue with your SQL code?

Try a var_dump() on the $query variable..


Fatal error: Call to a member function row() on a non-object - El Forum - 08-25-2007

[eluser]glemigh[/eluser]
Can you issue a similar MySQL statment in phpMyAdmin or like tool?


George


Fatal error: Call to a member function row() on a non-object - El Forum - 08-25-2007

[eluser]BrandonDurham[/eluser]
It works fine if I use that same query directly in PHPMyAdmin's SQL window.


Fatal error: Call to a member function row() on a non-object - El Forum - 08-25-2007

[eluser]Michael Wales[/eluser]
Is the database library being included? I would assume so, since db->query didn't issue the error.


Fatal error: Call to a member function row() on a non-object - El Forum - 08-26-2007

[eluser]NemetraL[/eluser]
Post the var_dump() so that we can see what's inside.. ;-)


Fatal error: Call to a member function row() on a non-object - El Forum - 08-26-2007

[eluser]BrandonDurham[/eluser]
I'm an idiot.

That query used to be an insert and is now an update. That's why it's not returning any rows.

Sorry for not catching that sooner. Thanks for the help.


Fatal error: Call to a member function row() on a non-object - El Forum - 08-26-2007

[eluser]glemigh[/eluser]
I thought of that this morning, apparently sleep helps, glad you were able to discover the problem.

George