Welcome Guest, Not a member yet? Register   Sign In
How to avoid errors in view when I am using variable for the php session
#1

[eluser]shinokada[/eluser]
I am using php session.

In a view when I use the following code, I get the error notice.

It is not displayed, but when I see the source code, it's there.

In a view:

Code:
$totalprice = $_SESSION['totalprice'];

Error

Code:
<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message:  Undefined index:  totalprice</p>
<p>Filename: controllers/mycontroller.php</p>
<p>Line Number: 326</p>

If I put it a controller, I get another error.

In a controller:
Code:
$data['totalprice']= $_SESSION['totalprice'];

Error

Code:
<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message:  Undefined index:  totalprice</p>
<p>Filename: controllers/mycontroller.php</p>
<p>Line Number: 326</p>

The second case is worse since the doc type and other header section is gone.

Can anyone tell me how to do it?

(Please don't ask me or why I am not using ci session class.)


Messages In This Thread
How to avoid errors in view when I am using variable for the php session - by El Forum - 01-10-2010, 06:20 AM



Theme © iAndrew 2016 - Forum software by © MyBB