Welcome Guest, Not a member yet? Register   Sign In
why is this code failing?
#3

(This post was last modified: 07-02-2020, 05:19 AM by richb201.)

Shy Thanks. How stupid of me. What I am really trying to do is add a few more fields into the table.

      $insert = array($this->url_field => $file_name);
      array_push($insert,'email => ' . $this->session->userdata('userid'));  <<trying to add two more fields before doing the insert
      array_push($insert,'campaign =>' .  $this->session->userdata('campaign'));
      $this->ci->db->insert($this->table_name, $insert);

This is failing with "call to a member function userdata() on null". So it seems that my image_CRUD.php module (which is in libraries) cannot load the session data. I tried adding $this->load->library('session'); to the Constructor in image_CRUD.php  but that fails. Since session is related to cookies, I figure that won't work either.  I tried a call (within image_CRUD.php) to $campaign= $this->session->userdata('campaign'); but this returns an error "Call to a member function userdata() on null". Any idea how to fix this? 

The problem is that I need to get those two variables, email and campaign into two  columns in the database record and can't seem to get them transferred to a different module. Any idea how to do this? 




also, where did the docs for CI 3 go??
proof that an old dog can learn new tricks
Reply


Messages In This Thread
why is this code failing? - by richb201 - 07-01-2020, 03:49 AM
RE: why is this code failing? - by neuron - 07-01-2020, 05:04 AM
using session data between a controller and a library - by richb201 - 07-01-2020, 08:26 AM
RE: why is this code failing? - by InsiteFX - 07-03-2020, 06:59 AM
RE: why is this code failing? - by ivantcholakov - 07-03-2020, 08:01 AM
RE: why is this code failing? - by richb201 - 07-03-2020, 09:04 AM
RE: why is this code failing? - by richb201 - 07-06-2020, 03:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB