Reference - What does this error mean in PHP? 34 answers
code:
Error :
how to fix that?
BeebrabieBeebrabie
marked as duplicate by RiggsFolly phpJan 8 '17 at 16:05
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
6 Answers
Define the variables at the beginning of the function so if there are no records, the variables exist and you won't get the error. Check for null values in the returned array.
You should initialize your variables outside the while loop. Outside the while loop, they currently have no scope. You are just relying on the good graces of php to let the values carry over outside the loop
alternatively, it looks like you are just expecting a single row back. so you could just say
I would guess your query isn't running as expected and you are getting to the return line with undefined variables.
Also, the way you are doing the variable assignment, you would be overwriting the same variable with each loop iteration, so you wouldn't return the entire result set.
Finally, it seems odd to return a numerically-keyed result set instead of an associatively-keyed one. Consider naming only the fields needed in the SELECT and keeping the key assignments. So something like this:
You might also consider opening a question about how to improve your query, is it is pretty heinous as it stands now.
Not the answer you're looking for? Browse other questions tagged phpundefinednotice or ask your own question.
I have Placed the codeigniter code controller and it throws a error Call to undefined method CI_Controller::CI_Controller().Pls help me to rectify the issue. Controller:
user2991258user2991258
4 Answers
That's not how you call the parent constructor. See this
marked as duplicate by Madara Uchiha♦, Dejan Marjanovic, ComFreek, PeeHaa, GlavićOct 13 '13 at 17:26
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
4 Answers
I don't see php file, but that could be that - replace in your php file:
Titan Quest PC Game OverviewTitan Quest is developed. Titan quest download igg. The world has been under the control of Beasts and monstrous creatures. The character that you have to play with starts his game on a dirt road near a village, Helos. It was released on 26 June 2006 for Microsoft Windows and THQ published this game.u game has a story that there is a disconnection between the humanity and gods.
with:
Most probably, at first time you running your script without ?query_age=[something] and $_GET has no key like query_age.
if you use isset like the answer posted already by singles, just make sure there is a bracket at the end like so: $query_age = (isset($_GET['query_age']) ? $_GET['query_age'] : null);
NSDestr0yerNSDestr0yer
Not the answer you're looking for? Browse other questions tagged phphtml or ask your own question.
This question already has an answer here:
“Notice: Undefined variable”, “Notice: Undefined index”, and “Notice: Undefined offset” using PHP 28 answers
I received the following error message when I go on searchproduct page. How may i fixed it?
Notice: Undefined index: dosageForm in C:xampphtdocsprismsearchproduct.php on line 29
Notice: Undefined index: dosageForm in C:xampphtdocsprismsearchproduct.php on line 32
Notice: Undefined index: strengths in C:xampphtdocsprismsearchproduct.php on line 35
Notice: Undefined index: strengths in C:xampphtdocsprismsearchproduct.php on line 38
i am getting same type of error ,
please help me to resolve
Sohan SonarSohan Sonar
marked as duplicate by Your Common Sense mysqliSep 30 '16 at 12:14
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
1 Answer
use isset()
or in your case : empty()
Update:
PHP7.1 allow this one too but it will may be forbidden by CodeStyle's rules
Gectou4Gectou4
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Not the answer you're looking for? Browse other questions tagged phphtml or ask your own question.