Undefined index: id error - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Undefined index: id error (/showthread.php?tid=2439) |
Undefined index: id error - El Forum - 08-06-2007 [eluser]phpworker[/eluser] Hello there, seems this is my second post here OK, this is the problem: I am creating my first bigger project with CI and there's a problem I do not understand. I have the following code in my main controller: Code: $q = 'select login,password,name,surname,group_id from '.$this->tb['users'].' where login="'.$data['login'].'" and password="'.$data['password'].'" and name="dsdsdsd"'; And that gives me errors like "Undefined index: id" but $query->num_rows() gives me 1. I also added in query one dummy value "dsdsdsd" for column "name" and still there is one row returned :/ It seems CI doesn't generate any results. I have no idea what to do to solve it. Any help, please? I use OCI8 with Oracle database v9.2. Of course connection with it was previously tested. Undefined index: id error - El Forum - 08-06-2007 [eluser]deviant[/eluser] You aren't actually selecting a column called id in that SQL query, so the array that the database library returns wont have that index. Undefined index: id error - El Forum - 08-06-2007 [eluser]phpworker[/eluser] I've just added this code: Code: foreach ($query->list_fields() as $field) Code: ID Changed the case of columns names used with $r[] array but no positive result from it. Undefined index: id error - El Forum - 08-06-2007 [eluser]phpworker[/eluser] deviant: thanx, that's true I ommited it. Corrected now and the result is: Code: Undefined index: LOGIN Undefined index: id error - El Forum - 08-06-2007 [eluser]deviant[/eluser] Array keys are case sensitive as far as I know, make 'em lower case. Undefined index: id error - El Forum - 08-06-2007 [eluser]phpworker[/eluser] Just did it. This is updated version: Code: $q = 'select id,login,password,name,surname,group_id from '.$this->tb['users'].' where login="'.$data['login'].'" and password="'.$data['password'].'" and name="dsdsdsd"'; Result: Code: login num_rows=1 Undefined index: id error - El Forum - 08-06-2007 [eluser]phpworker[/eluser] Maybe this would help - here is table data and structure: Code: create table WPR_T_AQ_USERS also, in application/config/tb.php i have defined: Code: $config['users'] = 'wpr_t_aq_users'; Undefined index: id error - El Forum - 08-06-2007 [eluser]deviant[/eluser] Well you could try adding this somewhere to see exactly what you are getting back: Code: $result = $query->result_array(); Undefined index: id error - El Forum - 08-06-2007 [eluser]phpworker[/eluser] Well, just did it and the result is quite interesting: Quote:login num_rows=1 What you see, especially the word 'Goscie' is placed in ANOTHER table and this is name of the group of users. I removed $this->tb['users'] from the query and replaced it with 'wpr_t_aq_users' - no difference in results! Undefined index: id error - El Forum - 08-06-2007 [eluser]phpworker[/eluser] Maybe this would help - this is the content of the config/tb.php file: Code: <?php if (!defined('BASEPATH')) exit('No direct script access allowed'); |