CodeIgniter Forums
Database error, pulling my hair out now... - 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: Database error, pulling my hair out now... (/showthread.php?tid=23491)



Database error, pulling my hair out now... - El Forum - 10-13-2009

[eluser]Militis[/eluser]
Hi there. I'm developing a new app with CodeIgniter (not my first one either), and am having some weird issues with my database.

I've var_dump'd my query and result, and here's what I see:

Code:
object(CI_DB_mysql_result)#20 (7) {
  ["conn_id"]=>
  resource(31) of type (mysql link persistent)
  ["result_id"]=>
  resource(49) of type (mysql result)
  ["result_array"]=>
  array(0) {
  }
  ["result_object"]=>
  array(0) {
  }
  ["current_row"]=>
  int(0)
  ["num_rows"]=>
  int(0)
  ["row_data"]=>
  NULL
}
array(0) {
}

A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: models/tsheets_model.php

Line Number: 51
A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

UPDATE `users` SET `uses_tsheets` = '1' WHERE `user_id` =

Here's the relevant code:

Code:
$query = $this->db->get_where('users', array('user_id' => $id), '1');
$result = $query->row();
var_dump($query);
var_dump($result);

I'm 100% positive my database is set up correctly in config, and there aren't any typos in my code (I've even copy/pasted from a WORKING database driven app, and still get the errors).


Database error, pulling my hair out now... - El Forum - 10-13-2009

[eluser]imn.codeartist[/eluser]
the error showing the result that you have an error at your update query so paste your model here


Database error, pulling my hair out now... - El Forum - 10-13-2009

[eluser]Militis[/eluser]
Ugh...Forgive me...It's amazing how arrogant you get at 2 am. >.<

I was trying to get session data using
Code:
$this->session->flashdata('item');
instead of
Code:
$this->session->userdata('item');

The session data wasn't loaded in flash data...>.>

Sorry to bother everyone.


Database error, pulling my hair out now... - El Forum - 10-14-2009

[eluser]markup2go[/eluser]
That's ok, we all have goof ups like this at times. Smile