• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
accessing a $_SESSION variable is failing

#1
I have a little code sitting in a php file that is in the assets directory. I know that is not normal, but this is where the vendor keeps it. When that code runs the line below is executed. 

$campaign=$this->$_SESSION['campaign'];

However,  $campaign yields null (as seen in the debugger). But when I look at it in the debugger, $_SESSION[campaign'] has the string "Apple" in it. How can I get the value of the $_SESSION into the variable $campaign?
proof that an old dog can learn new tricks
Reply

#2
Is the session started by you or the file in the assets vendor?

If the session is already started you should be able to get like below.

PHP Code:
$campaign $_SESSION[campaign']; 

try that.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
That worked to load $campaign. I am having a problem with the query
->query("SELECT bus_comp FROM business_components WHERE campaign=$campaign AND email='[email protected]'")

I get :
An uncaught Exception was encountered
Type: Error
Message: Call to a member function execute() on boolean
Filename: /app/vendor/koolreport/core/src/datasources/MySQLDataSource.php
Line Number: 384
proof that an old dog can learn new tricks
Reply

#4
Solved. I needed to use '$campaign' in the query string.

Thx
proof that an old dog can learn new tricks
Reply

#5
If you using double quotes you can do it like this.

PHP Code:
{$campaign
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#6
I am trying to build a string to use in this cmd

$cmd = "soffice --convert-to png ".$inputFile." --outdir ". $ouputDirectory;

I tried using $inputFile="/app".{$field_info['upload_path']}; to build the input file name. But I get this error:

Error: Cannot use object of type stdClass as an array

$field_info is coming from the function:

function callback_after_upload2($uploader_response,$field_info, $files_to_upload){}
proof that an old dog can learn new tricks
Reply

#7
Try this and let me know if it works.

PHP Code:
$cmd "soffice --convert-to png {$inputFile} --outdir {$ouputDirectory}"
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#8
(07-16-2020, 07:54 AM)InsiteFX Wrote: Try this and let me know if it works.

PHP Code:
$cmd "soffice --convert-to png {$inputFile} --outdir {$ouputDirectory}"
The problem is getting the $inputFile.


$inputFile="/app".$field_info['upload_path'];

This is in a call back where $field_info is  a structure being passed to the callback. upload_path contains the full path to the file that was just uploaded. I need to add /app onto the front of it. But I can't seems to access $field_info['upload_path']. 
proof that an old dog can learn new tricks
Reply

#9
Can you do a var_dump of it?

PHP Code:
var_dump($field_info['upload_path']);
exit(); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#10
(07-16-2020, 11:17 AM)InsiteFX Wrote: Can you do a var_dump of it?

PHP Code:
var_dump($field_info['upload_path']);
exit(); 
I get the same error: cannot use object of type stdClass as array
proof that an old dog can learn new tricks
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.