Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
My page returns this error:
Fatal error: Call to undefined function session_set()>in /home/a7714221/public_html/index.php on line 5
My code is long on the page that returns the error but the only thing that could cause it of course is the session_set()
Anybody know the fatal error that I've inadvertently made? :)
EDIt: I'm trying to pass variables across several pages. Specifically, take $_POST data, subtract it from another variable then ask the user to enter another value and subtract it from (previous post data - afore mentioned variable) and so on until it reaches 0.
There is no function session_set(), hence the fatal error. You tried to call a function that does not exist.
To set a session variable, you access it via the $_SESSION array.
So to set a $_SESSION variable, just like any other array
$_SESSION['foo'] = 'bar';
# Access a session var
echo $_SESSION['foo'] # Prints 'bar'
Further Reading from the docs
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I'm trying to add two $_POST variables, like so:
$points = $_POST['old_points'] + $_POST['new_points'];
(Line 48)
Which works fine, except it produces the following error:
Notice: A non well formed numeric value encountered in F:\xampp\htdocs\test\index.php on line 48
I can't figure out what the problem is here.
may be you need convert the content of $post as a correct number
$points = floatval($_POST['old_points']) + floatval($_POST['new_points']);
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am new here, so please bear with me.
Am trying to run a project built using the codeigniter.
The project is an online registration system,but am getting the undefined variable error in some parts of my page.
Please if you got the time to go over the project and help me out I will be very grateful.
Here is the link to the whole system.
NB:It contains the exported database already( the database is called 'orsdb' )
Cheers!!!
https://drive.google.com/open?id=0ByYO-aax6KH3cnJNRnBsNEgwd1k
You should check every variable in your CI view part before printing it, you can use isset() to check you variable is either define or not. Example -
<?php echo isset($var) ? $var:""; ?>
You can also use empty() function to check variables.
Another thing is if your variable is always undefined then you must check your array which contains data fetching from database in CI controller and print the array to check your all required value does exist or not. If not exists then check your SQL query whether it fetches your required data or not.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I am running an php website in xaamp server and while running i am getting this error, what does it means? and how do i solve this?
Undefined variable: _SESSION in C:\xampp\htdocs\web\Movie\admin.php on line 56
It most likely means you need to add session_start(); to the very top of your php page.
It means you are referencing the _SESSION variable without declaring it anywhere. Go to line 56 in your admin.php file to locate the reference. Once you find the reference you can then decide where to place the session_start() function call in your code to initialize _SESSION
For more info on session variables and _SESSION visit the PHP documentation page here.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
In opencart, I have a variable sales_representative in a foreach loop. It gets defined and put into an array, then gets out-put in a .tpl file. Everything works as it should. But I get a notice up top saying undefined index: sales_representative... If it was undefined I wouldn't be getting a result displayed... Any thoughts?
Make sure before you give it any value, initialize it first outside the loop by giving it a value of either 0 or ""
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 7 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I have a line of code that simply calls a function with a number of parameters (actually 14 of them...).
It doesn't access an array value (i.e. doesn't do array[i]).
list($fs_response, $flume_response, $create_queues_response, $hdfs_response, $impala_msg) = performAllUpdates($fs_backup, $new_item, $flume, $flume_backup, $logger, $hdfs_backup, $hdfs_local_copy, $properties, $env, $hdfs_controller, $python, $hdfa_response, $impala_msg, $create_queues_response);
However I'm getting a Notice: Undefined offset: 4 on this line for some reason.
Any idea?
In order for you to successfully extract an array of 5 elements like you tried via "list", you need to make sure the performAllUpdates function returns an array of 5 elements minimum. For example, the following return statement in the function will work:
return array($response1,$response2,$response3,$response4,$response5);
But of course $response1 through $response5 need to be replaced with actual values or variables used in the function.
I also recommend modifying the function to return the array always, and if the function is meant to produce an error based on invalid input, then put in invalid values for the array. For example, you can use this return statement to show an error:
return array(-1,-1,-1,-1,-1);
That way, your attempt to receive 5 elements will always be successful and then you can test the results by checking the values of any of the 5 variables you asked for from the function.