How to Fix PHP Notice: Undefined index?

Ever struggled hours and hours to figure out a fix for this notice?

Undefined-index

First of all let us understand the problem.It should be clearly understood that this is NOT an ‘Error’, but a ‘Notice’. A notice can be ignored if it’s not critical while an error must be fixed. You might have observed that even though a notice appears, rest of the output will be displayed on the browser.

Coming back to our topic, when the ‘Undefined index’ notice occurs, most of the time it is a good practice to fix this than ignoring.

How to Fix

One simple answer – isset() !

isset() function in PHP determines whether a variable is set and is not NULL. It returns a Boolean value, that is, if the variable is set it will return true and if the variable value is null it will return false.

More details on this function can be found in PHP Manual.

Example

Let us consider an example.

Below is the HTML code for a comment form in a blog.

<form name="myform" id="myform" method="post" action="add_comment.php">
    <h2>Please leave a comment:</h2>
    <input type="text" id="username" name="username" value="Enter Username" /><br />
    <input type="text" id="email" name="email" value="Enter Email" /><br />
    <textarea id="comment" name="comment">Enter Comment</textarea><br />
    <br /><br />
    <input type="checkbox" id="notify_box" name="notify_box" value="Y">
    Notify me when a new post is published. <br />
    <br />
    <input type="submit" value="Post Comment">
</form>

Here is the PHP file ‘add_comment.php’ which takes the data passed from the comment form.

<?php
    $uName  = $_POST['username'];
    $eMail  = $_POST['email'];
    $comment= $_POST['comment'];
    $notify = $_POST['notify_box'];
    // send the data to the database
?>

What happens is, when the check-box is CHECKED, the code works fine. But when it is not, then I am getting the warning as mentioned above.

Warning: Undefined index:

So to fix this, let us make use of the magic function. Now the code appears like this.

<?php
    $notify = "";
    $uName  = $_POST['username'];
    $eMail  = $_POST['email'];
    $comment= $_POST['comment'];
    if(isset($_POST['notify_box'])){ $notify = $_POST['notify_box']; }
    // send the data to the database
?>

What happens here is, I am checking first whether the check box is CHECKED (or set) using a condition. And if the condition is true I am getting the value passed.

The same fix can be used for the above warning when working with $_SESSION, $_POST arrays.

But, there instances where harmless notices can be ignored.

For an example,

I have a page which can be accesses in below 3 ways.

www.someexample.com/comments.php

www.someexample.come/comments.php?action=add

www.someexample.com/comments.php?action=delete

All these URL’s go to the same page but each time performs a different task.

So when I try to access the page through the first URL, it will give me the ‘Undefined index’ notice since the parameter ‘action’ is not set.

We can fix this using the isset() function too. But on this instance, we can just ignore it by hiding the notices like this.

error_reporting(E_ALL ^ E_NOTICE);

You can also turn off error reporting in your php.ini file or .htaccess file, but it is not considered as a wise move if you are still in the testing stage.

This is another simple solution in PHP for a common complex problem. Hope it is useful.

Tags: #

Get Updates

Spread the Word

What’s Next?

103 Responses to "How to Fix PHP Notice: Undefined index?"

  1. Neck pain relief says:

    You have some genuinely beneficial information composed here. Good job and keep posting good stuff.

  2. Humberto Dingess says:

    Hey, thanks for the blog post. Cool.

  3. have never thought that surfing online can be so much beneficial and having found your blog I feel really happy and grateful for providing me with such priceless information.

  4. Major thanks for the blog.Thanks Again. Really Great.

  5. Engin says:

    Thanks it helped me !

  6. Chria says:

    Thanks Man…Well Done..

    Thanks again for your sharing your knowledge!!

  7. Chandima Vitharana says:

    Thanks all for your feedback. Happy the article was of great use!

  8. Thank you for sharing this, i found it very useful,
    error_reporting(E_ALL ^ E_NOTICE); – is GENIOUS!

  9. Ruchi Choudhary says:

    Can u help me? I hv same type of problem and tried to solve it by both ways as u tell but its not work.Here is my code:
    <?php
    $con = mysql_connect("localhost","root","");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }
    mysql_select_db("genomics", $con);
    $Accession = $_GET['Accession'];
    $Locus = $_GET['Locus'];
    $Definition = $_GET['Definition'];
    $Sequencetype = $_GET['Sequencetype'];
    $Sequencelength = $_GET['Sequencelength'];
    $Version = $_GET['Version'];
    $GI = $_GET['GI'];
    $Organism = $_GET['Organism'];
    $Authors = $_GET['Authors'];
    $Publication = $_GET['Publication'];
    $Labaddress = $_GET['Labaddress'];
    $Dateofsequencesubmission = $_GET['Dateofsequencesubmission'];
    $collabrationown = $_GET['collabrationown'];
    $result = mysql_query("SELECT * FROM maintable WHERE Accession = '$Accession'");

    while($row = mysql_fetch_array($result))
    {
    echo "Accession “;
    echo “Locus “;
    echo “Sequence length “;
    echo “Sequence type “;
    }

    mysql_close($con);
    ?>

    and showing
    Undefined index: Locus in C:\wamp\www\main2.php on line 10

    • Chandima Vitharana says:

      Hi Ruchi,

      We might have to look into the code of the page where you GET the data from. Seems like it’s probably an incorrect index name. However I need more data. Please email me the codes for both pages (or maybe all the code in one page) to the following email address:
      chandivitharana[at]gmail[dot]com

      I’ll sure help you out with this.

    • Good Muyis says:

      @Ruchi Choudhary
      The Problem you have is not on line 10 only it will extend to line 21 where you have $collabrationown,this E_NOTICE started in latest versions of PHP because i have create a website using a PHP version that comes with XAMPP 1.7.0, without the E_NOTICE,but on later version its started.
      You can probably suppress the E_NOTICE if you are sure if everything is going well with your Script.

      But am hoping for a better way to deal with the “Notice: Undefined index” without stress siting your code as example

    • Rey Eduardo says:

      Just put an @ before declaring variables

      Example:
      @$username = $_POST['username'];
      @$password = $_POST['password'];

    • Ruben Sinayon says:

      Better to use isset() function. isset function can defined the value of the text field. thats only locking with your codes.

  10. AP Dubey says:

    Thanks a lot buddy…

    I am new for php and I was having same issue in y test page ..got your blog and issue solve..

    Thanks for crisp and straight solution

    Thanks a lot
    AP Dubey

    • Chandima Vitharana says:

      Appreciate your comment Dubey.
      Will write more PHP fixes. In the meantime if you encounter more problems do not hesitate to contact NOG team.

  11. Nina says:

    I’m another grateful reader.

  12. Sara says:

    Wonderful, really.
    You saved me (and many others I believe) a lot of work hours. And madness :)

  13. Isa says:

    Great help, thanks.

  14. babak says:

    i solve it by this way

  15. Dilshi says:

    How To Insert Data Into MySQL db using form in php

    <?php
    $Submit;
    if (isset($_POST['Submit'])) {

    $sql = "INSERT INTO reg(Name ,Email) values ('".mysql_real_escape_string(stripslashes($_POST['Name']))."','".mysql_real_escape_string(stripslashes($_POST['Email']))."')";
    if($result = mysql_query($sql ,$db)) {
    echo 'Thank youYour information has been entered into our database
    How To Insert Data Into MySQL db using form in phpBy Webune.com

    Name:

    Email:

    I FOUND ERROR OF UNDEFINED INDEX.PLEASE HELP ME

    • Chandima Vitharana says:

      Dilshi,
      If you haven’t solved the problem yet, please do email me the code. I’ll take a look.
      chandivitharana[at]gmail[dot]com

  16. Tanuja says:

    Hi , Thanks a lot . I faced the same error now my problem solved. very good blog

  17. Rishabh says:

    Thank u very much..

  18. bbmak0 says:

    So this whole thing has to add it to avoid the null value submission unidentified index?

    if(isset($_POST['notify_box'])){ $notify = $_POST['notify_box']; }

    I usually do the validation check after the value identified. I sometime get the Undefined index

    • Chandima Vitharana says:

      well bbmak0, it is a good practice to use isset() for tricky places. Undefined index is the most common php error and my article is a general guide. You can get the cue and explore more efficient ways. :)

  19. আবু ফয়সাল আহেমদ says:

    Thank you very much. it is straight forward and easy to understand!
    I wud like to visit the page more often.

  20. Black Eagle says:

    Useful information , thanks.

  21. leslie shang-simpson says:

    Chandima, it’s a very good thing you’re doing to help rookies like myself. Cudos to you and more grease to your elbow.
    NB: I sent you a mail with some screen shot of my error and the relevant codes. Hope you get it so you assist me in resolving the issue.
    Thanx man!

    • Chandima Vitharana says:

      Hi Leslie,
      I believe I promised to take a look at your code but I guess I accidentally deleted your mail.
      Hope you have solved the problem by now. If not please be kind enough to resend the email with the codes and I’ll assure you to give a prompt reply.

      Thanks. :)

  22. nader says:

    <?php

    $id_c=$_GET["id_c"];
    mysql_connect("127.0.0.1","root", "");
    mysql_select_db("base1");
    $sql = "select * from compte_client where id_c='$id_c'" ;
    $req = mysql_query($sql) or die('Erreur SQL !’.$sql.”.mysql_error());
    $data = mysql_fetch_assoc($req);

    if($data['id_c'] = $id_c) {
    ?>

    Modifier Client

    Num:
    <input type="text" name="num" id="" size="54" value="” />

    Nom:
    <input type="text" name="nom" id="" size="54" value="” />
    <input type="hidden" value="” name=”id”>

    Adresse_email:
    <input type="text" name="adresse_email" id="" size="54" value="” />

    <?php
    Notice: Undefined index: id_c in C:\Program Files\EasyPHP-12.1\

  23. ibrahim says:

    but what will happend if it has more tahn 50 values.
    then if else will be checked more than………

  24. Fabio says:

    Thank you so much

    I a a bit a of a beginner with web dev and php and this helped me so much.

    Have a great day!

    • Chandima Vitharana says:

      Hi Fabio,
      Glad this article was of help to you. However this is a general guide. Research more on this and try to come up with great solutions. And please don’t forget to share your findings too. :)

  25. I carry on listening to the rumor lecture about receiving free online grant applications so I have been looking around for the finest site to get one. Could you advise me please, where could i acquire some?

    | Guidelines For Major Aspects In Juicer Reviews

  26. William Cai says:

    Dear Chandima,
    I met the same problem as you mentioned above, I use the same way but it looks like not working. I sent an email to you, I am appreciated that you can help me solve this problem, I am also a fresher for PHP. Have a nice weekend.

    • Chandima Vitharana says:

      William,
      I hope the the suggestions I gave you will help you solve the problem. However do contact me if you require further assistance.
      You too have a great weekend! Cheers.

    • Chandima Vitharana says:

      Hi Goodmuyis,
      Great solution!
      My article here provides the basic guidance on fixing this issue mainly targeted for absolute beginners.
      Glad that someone got the cue and worked on many more effective solutions (such as checking number for variables).
      Please do write more fixes and share them here.
      Cheers!

  27. Chandima Vitharana says:

    Hi Goodmuyis,

    Great solution! :)
    My article here provides the basic guidance on fixing this issue mainly targeted for absolute beginners.
    Glad that someone got the cue and worked on many more effective solutions (such as checking number for variables).

    Please do write more fixes and share them here.
    Cheers!

  28. William Cai says:

    unfortunately, I can not catch up the website what Goodmuyis said, does it blocked in China?

  29. William Cai says:

    Dear Chandi,
    I find if I use the original code to run the user authorization application, even though it display the Notice(below), all other function are looks functional. So it looks like these two code line(//create short variable names) are not needed. would you please tell me what’s the purpose for these two code?
    Whenever I want to use the link to go to member.php, it always comes out these two “Notice”.

    Thank you very much!

  30. William Cai says:

    No One help me?

  31. This post gave me the answer I was looking for. You definitely saved me time.

    Thank you very much!

  32. leslie shang-simpson says:

    I’ve been struggling with this error for some time now. Can anyone help me out.

    Notice: Undefined index: POS in c:\bobs\middle\business\session.php on line 65
    Notice: Undefined index: type in c:\bobs\middle\presentation\controller.php on line 48
    Notice: Undefined index: login in c:\bobs\middle\presentation\controller.php on line 48
    Notice: Undefined index: cmd in c:\bobs\middle\presentation\controller.php on line 48

    getProperty(‘type’);
    if($type == ‘xml’){
    // Is an ajax request.
    $msg = ‘The session is over.’;
    Page::display(array(‘message’ => $msg), ‘logout_xml.tpl’);
    return;
    }

    $module_title = POS_TITLE;

    // Verify if the submit button of the login form was pressed.
    if(is_null($request->getProperty(‘login’))){
    // Check if the user was kicked out or was sending a command.
    if(!is_null($request->getProperty(‘cmd’))){
    $notify = 1;
    $msg = ‘The session is over. Enter again.’;
    }

    Page::display(array(‘module_title’ => $module_title, ‘notify’ => $notify,
    ‘message’ => $msg, ‘date’ => date(‘d/m/Y’)), ‘login_pos_form_html.tpl’);
    return;
    }

    // If the submit button was pressed.
    $username = $request->getProperty(‘username’);
    $password = $request->getProperty(‘password’);
    $date = $request->getProperty(‘date’);

    try{
    if(!UserAccountUtility::isValid($username, $password)){
    $msg = ‘Invalid username or password.’;
    Page::display(array(‘module_title’ => $module_title, ‘username’ => $username,
    ‘date’ => $date, ‘notify’ => ’1′, ‘message’ => $msg), ‘login_pos_form_html.tpl’);
    }
    else{
    $user = UserAccount::getInstance($username);

    if(AccessManager::isAllowed($user, ‘pos’, ‘access’)){
    $working_day = WorkingDay::getInstance($date);
    $helper->setUser($user);
    // Sorry, bad practice necessary.
    $helper->setWorkingDay($working_day);
    header(‘Location: index.php’);
    }
    else{
    $msg = ‘Access is denied’;
    Page::display(array(‘module_title’ => $module_title, ‘username’ => $username,
    ‘date’ => $date, ‘notify’ => ’1′, ‘message’ => $msg), ‘login_pos_form_html.tpl’);
    }
    }
    } catch(Exception $e){
    $msg = $e->getMessage();
    Page::display(array(‘module_title’ => $module_title, ‘username’ => $username,
    ‘date’ => $date, ‘notify’ => ’1′, ‘message’ => $msg), ‘login_pos_form_html.tpl’);
    }
    }
    }
    ?>

    _mProperties = $_REQUEST;
    return;
    }

    foreach($_SERVER['argv'] as $arg){
    if(strpos($arg, ‘=’)){
    list($key, $val) = explode(‘=’, $arg);
    $this->setProperty($key, $val);
    }
    }
    }

    /**
    * Returns an item of the properties array.
    * @param string $key
    * @return string
    */
    public function getProperty($key){
    return $this->_mProperties[$key];
    }

    /**
    * Sets an item in the properties array.
    * @param string $key
    * @param string $val
    */
    private function setProperty($key, $val){
    $this->_mProperties[$key] = $val;
    }
    }

    /**
    * Defines common functionality for derived controller classes.
    * @package Controller
    * @author Leslie
    */
    abstract class Controller{
    /**
    * Holds the session helper.
    * @var SessionHelper
    */
    protected $_mHelper;

    /**
    * Private constructor to make the run method the only way.
    */
    protected function __construct(){}

    /**
    * It starts to run the system.
    *
    * It obtains and executes the command in the cmd argument provided by the user.
    */
    abstract static public function run();

    /**
    * Obtains and sets the session helper.
    */
    protected function init(){
    $this->_mHelper = ActiveSession::getHelper();
    }

    /**
    * Handles the request from the user.
    */
    protected function handleRequest(){
    $request = new Request();

    // Check if the user has already login.
    if(!is_null($this->_mHelper->getUser())){
    $cmd = $request->getProperty(‘cmd’);
    if($cmd == ”){
    $command = $this->getDefaultCommand();
    $command->execute($request, $this->_mHelper);
    return;
    }

    $command = CommandResolver::getCommand($cmd);
    if(is_null($command)){
    // If the command provided was not found.
    $command = $this->getNotFoundCommand();
    $command->execute($request, $this->_mHelper);
    }
    else
    $command->execute($request, $this->_mHelper);
    }
    else{
    $command = $this->getNotLoginCommand();
    $command->execute($request, $this->_mHelper);
    }
    }

    /**
    * Returns the default command for the controller.
    * @return Command
    */
    abstract protected function getDefaultCommand();

    /**
    * Returns the default NotFoundCommand for the controller.
    * @return Command
    */
    abstract protected function getNotFoundCommand();

    /**
    * Returns the default NotLoginCommand for the controller.
    * @return Command
    */
    abstract protected function getNotLoginCommand();
    }

    /**
    * Executes the inventory side of the system.
    * @package Controller
    * @author Leslie
    */
    class InventoryController extends Controller{
    /**
    * It starts to run the system.
    *
    * It obtains and executes the command in the cmd argument provided by the user.
    */
    static public function run(){
    $instance = new InventoryController();
    $instance->init();
    $instance->handleRequest();
    }

    /**
    * Returns the default command for the controller.
    * @return Command
    */
    protected function getDefaultCommand(){
    return CommandResolver::getCommand(‘show_home_inventory’);
    }

    /**
    * Returns the default NotFoundCommand for the controller.
    * @return Command
    */
    protected function getNotFoundCommand(){
    return CommandResolver::getCommand(‘show_not_found_inventory’);
    }

    /**
    * Returns the default NotLoginCommand for the controller.
    * @return Command
    */
    protected function getNotLoginCommand(){
    return CommandResolver::getCommand(‘login_inventory’);
    }
    }

    /**
    * Executes the administration side of the system.
    * @package Controller
    * @author Leslie
    */
    class AdminController extends Controller{
    /**
    * It starts to run the system.
    *
    * It obtains and executes the command in the cmd argument provided by the user.
    */
    static public function run(){
    $instance = new AdminController();
    $instance->init();
    $instance->handleRequest();
    }

    /**
    * Returns the default command for the controller.
    * @return Command
    */
    protected function getDefaultCommand(){
    return CommandResolver::getCommand(‘show_home_admin’);
    }

    /**
    * Returns the default NotFoundCommand for the controller.
    * @return Command
    */
    protected function getNotFoundCommand(){
    return CommandResolver::getCommand(‘show_not_found_admin’);
    }

    /**
    * Returns the default NotLoginCommand for the controller.
    * @return Command
    */
    protected function getNotLoginCommand(){
    return CommandResolver::getCommand(‘login_admin’);
    }
    }

    /**
    * Executes the POS side of the system.
    * @package Controller
    * @author Leslie
    */
    class POSController extends Controller{
    /**
    * It starts to run the system.
    *
    * It obtains and executes the command in the cmd argument provided by the user.
    */
    static public function run(){
    $instance = new POSController();
    $instance->init();
    $instance->handleRequest();
    }

    /**
    * Returns the default command for the controller.
    * @return Command
    */
    protected function getDefaultCommand(){
    return CommandResolver::getCommand(‘show_home_pos’);
    }

    /**
    * Returns the default NotFoundCommand for the controller.
    * @return Command
    */
    protected function getNotFoundCommand(){
    return CommandResolver::getCommand(‘show_not_found_pos’);
    }

    /**
    * Returns the default NotLoginCommand for the controller.
    * @return Command
    */
    protected function getNotLoginCommand(){
    return CommandResolver::getCommand(‘login_pos’);
    }
    }

    /**
    * Executes the POS Admin side of the system.
    * @package Controller
    * @author Leslie
    */
    class POSAdminController extends Controller{
    /**
    * It starts to run the system.
    *
    * It obtains and executes the command in the cmd argument provided by the user.
    */
    static public function run(){
    $instance = new POSAdminController();
    $instance->init();
    $instance->handleRequest();
    }

    /**
    * Returns the default command for the controller.
    * @return Command
    */
    protected function getDefaultCommand(){
    return CommandResolver::getCommand(‘show_home_pos_admin’);
    }

    /**
    * Returns the default NotFoundCommand for the controller.
    * @return Command
    */
    protected function getNotFoundCommand(){
    return CommandResolver::getCommand(‘show_not_found_pos_admin’);
    }

    /**
    * Returns the default NotLoginCommand for the controller.
    * @return Command
    */
    protected function getNotLoginCommand(){
    return CommandResolver::getCommand(‘login_pos_admin’);
    }
    }

    /**
    * Class in charge of obtaining the requested command.
    * @package Controller
    * @author Leslie
    */
    class CommandResolver{
    /**
    * Returns an instance of the command name provided.
    *
    * Returns NULL in case such command does not exists.
    * @param string $cmd
    * @return Command
    */
    static public function getCommand($cmd){
    if($cmd == ”)
    return NULL;

    $cmd = str_replace(array(‘.’, ‘/’), ”, $cmd);
    $file_path = COMMANDS_DIR . $cmd . ‘.php’;
    $class_name = self::getCommandName($cmd) . ‘Command’;
    if(file_exists($file_path)){
    require_once($file_path);
    if(class_exists($class_name)){
    $cmd_class = new ReflectionClass($class_name);
    return $cmd_class->newInstance();
    }
    }

    return NULL;
    }

    /**
    * Receives the name of the file of the command and it returns the formated name of the command.
    *
    * e.g. show_login_inventory, returns ShowLoginInventory.
    * @param string $cmd
    * @return string
    */
    static private function getCommandName($cmd){
    $cmd = str_replace(array(‘_’), ‘ ‘, $cmd);
    $cmd = ucwords($cmd);
    return str_replace(array(‘ ‘), ”, $cmd);
    }
    }
    ?>

    _mModuleName]['user'];
    }

    /**
    * Returns the key’s corresponding object.
    *
    * @param integer $key
    * @return variant
    */
    public function getObject($key){
    $this->validateKey($key);
    return $_SESSION[$this->_mModuleName]['objects'][$key];
    }

    /**
    * Returns the array of subjects cached.
    *
    * @return array
    */
    public function getSubjects(){
    return $_SESSION[$this->_mModuleName]['subjects'];
    }

    /**
    * Returns the array of actions cached.
    *
    * @return array
    */
    public function getActions(){
    return $_SESSION[$this->_mModuleName]['actions'];
    }

    /**
    * Sets the session’s user.
    *
    * @param UserAccount $user
    */
    public function setUser(UserAccount $user){
    $_SESSION[$this->_mModuleName]['user'] = $user;
    }

    /**
    * Stores an object or value in the session.
    *
    * @param integer $key
    * @param variant $obj
    */
    public function setObject($key, $obj){
    $this->validateKey($key);
    $_SESSION[$this->_mModuleName]['objects'][$key] = $obj;
    }

    /**
    * Sets the array of subjects cached.
    *
    * @param array $subjectsArray
    */
    public function setSubjects($subjectsArray){
    $_SESSION[$this->_mModuleName]['subjects'] = $subjectsArray;
    }

    /**
    * Sets the array of actions cached.
    *
    * @param array $actionsArray
    */
    public function setActions($actionsArray){
    $_SESSION[$this->_mModuleName]['actions'] = $actionsArray;
    }

    /**
    * Unsets the user from the session.
    *
    */
    public function removeUser(){
    $_SESSION[$this->_mModuleName]['user'] = NULL;
    }

    /**
    * Unsets the object from the session.
    *
    * @param integer $key
    */
    public function removeObject($key){
    $this->validateKey($key);
    $_SESSION[$this->_mModuleName]['objects'][$key] = NULL;
    }

    /**
    * Returns the instance of the session helper.
    *
    * @return SessionHelper
    */
    abstract static public function getInstance();

    /**
    * Validates if the value of the provided key is correct.
    *
    * Must be greater than cero.
    * @param integer $key
    * @throws Exception
    */
    protected function validateKey($key){
    if(!is_int($key) || $key _mModuleName]['working_day'];
    }

    /**
    * Sets the session’s working day.
    *
    * @param WorkingDay $workingDay
    */
    public function setWorkingDay(WorkingDay $workingDay){
    $_SESSION[$this->_mModuleName]['working_day'] = $workingDay;
    }

    /**
    * Returns the instance of the session helper.
    *
    * @return SessionHelper
    */
    static public function getInstance(){
    if(is_null(self::$_mInstance))
    self::$_mInstance = new POSSession();

    return self::$_mInstance;
    }
    }

    /**
    * Utility class for keeping session data on the POS Administration side of the system.
    * @package Session
    * @author Leslie
    */
    class POSAdminSession extends SessionHelper{
    /**
    * Name of the module in use.
    * @var string
    */
    protected $_mModuleName = ‘POS Admin’;

    /**
    * Instance of the helper.
    * @var SessionHelper
    */
    static protected $_mInstance;

    /**
    * Returns the instance of the session helper.
    *
    * @return SessionHelper
    */
    static public function getInstance(){
    if(is_null(self::$_mInstance))
    self::$_mInstance = new POSAdminSession();

    return self::$_mInstance;
    }
    }

    /**
    * Class for generating keys to identify objects in the session object.
    * @package Session
    * @author Leslie
    */
    class KeyGenerator{
    /**
    * Generates a random integer key between 1000 and 9999.
    * @return integer
    */
    static public function generateKey(){
    return rand(1000, 9999);
    }
    }
    ?>

  33. Leon says:

    Thanks, this was bugging me. I knew it wasn’t an error, but the perfectionist in me was unforgiving.

  34. wendy says:

    its still showing me this
    ( ! ) SCREAM: Error suppression ignored for
    ( ! ) Notice: Undefined variable: search in C:\wamp\www\dictionary\recover.php on line 32
    Call Stack. buh it still works. how do I get dis off.
    # Time Memory Function Location
    1 0.0011 143248 {main}( ) ..\recover.php:0

  35. Hello there! I know this is kind of off topic but I was wondering which blog
    platform are you using for this website? I’m getting sick and tired of WordPress because I’ve had issues with hackers and I’m looking at options for another platform. I would be fantastic if you could point me in the direction of a good platform.

  36. Dave Melia says:

    Thank you for posting this solution. Despite the fact that I can code whatever it is I need whenever I need it, I would not call myself a programmer (though that is my ambition). It never occurred to me to use conditional statements on declaring variables, and I will now keep that in mind for future projects. TIL something! :D

  37. Ajao Abayomi says:

    thanks alot, this assit to fix an error, have bin battling with….thanks

  38. Umair shah says:

    greate well work you solve my problem

  39. rahul says:

    Thank you for your reply

  40. geszn says:

    i have this on my code, then how to use isset format ?
    $count = count($_POST["data"]);

  41. Tisha says:

    i have problem with this code and error is Notice: Undefined index: name in C:\xampp\htdocs\2.php on line 8
    How can i fix this?Thanks

  42. Matthew says:

    I was suggested this blog through my cousin. I’m not positive whether this post is written by way of him as no one else recognise such distinctive approximately my trouble. You’re amazing!
    Thanks!

  43. clickmac says:

    wow! thanks alot dude!

  44. Click Here says:

    Thanks for sharing this is really Helpful blog post ,In the considering information and facts are and thus advantageous for everyone keep it up .
    Click Here

  45. Majid says:

    hi there
    i just can say a million thank’s . your code solved my problem

  46. sadhana says:

    thank you…….. really helpd

  47. Michael says:

    hi, it really did work for some part of the code but i’m still having an undefined index error on the fieldname on line 12, kindly help on it.
    30);
    foreach($fields_with_lengths as $fieldname => $maxlength){
    if(strlen(trim(mysql_prep($_POST['fieldname']))) > $maxlength){
    $errors[] = $fieldname;}
    }

    if(!empty($errors)){
    redirect_to(“new_subject.php”);
    }
    ?>

  48. learner says:

    just great , thanks a lot. It works for me …cool :D

  49. learner says:

    Can I send multiple parameters suppose name, email, website , comment and gender at a time through trim (), htmalspecialchararcters (), stripbackslashes () ?

    I am trying to validate the form data actually, I followed w3schools tutorial but, I do not understand their explanation.

  50. emo says:

    Thank you very much for all your help and useful information

  51. benny says:

    Undefined index: product_id in /home/tokoling/public_html/vqmod/vqcache/vq2-catalog_controller_module_sales_motivator.php on line 43

    line43 contains
    $product_id = $this->request->get['product_id'];

    Can you suggest me how to fix this

  52. Don Mickey says:

    try use this but first of all is the file name the same as where the code is?

    if(isset($_GET['product_id'])){$product_id = $this->request->get['product_id'];}

  53. Daniel says:

    THANKS MAN! CHEERS!

  54. I have been surfing online more than three hours today, yet
    I never found any interesting article like yours.
    It is pretty worth enough for me. In my view, if
    all website owners and bloggers made good content as
    you did, the web will be much more useful than ever before.

  55. sagar sonawane says:

    please help me with this i get this notice when i try to login ….Notice: Undefined index: log in C:\xampp\htdocs\tutorials\home.php on line 20

  56. Clare says:

    Awesome!! You saved me hours possibly days of trying to figure this out!
    Thanks!!

  57. sharukh says:

    if ($title && $name && $message)

    any help please??

  58. Amjad Ayub says:

    Problem solved.

    Thanks dear

  59. Don Mickey says:

    can some please check this site if its not a spam, i’ve tried on different forums but couldnt get any help from them
    http://2cashsite.com/?id=112230

  60. ron says:

    help!!! am getting this notice in my browser:
    Notice: Undefined index: ALL_HTTP in C:\xampp\htdocs\sandbox\irolm\site01\app\detect.php on line 118

    this is my code from line 115

    if(in_array($mobile_ua,$mobile_agents)){
    $mobile_browser++;
    }

    line118 is this one

    if (strpos(strtolower($_SERVER['ALL_HTTP']),’OperaMini’)>0) {
    $mobile_browser++;
    }
    if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),’iemobile’)>0) {
    $mobile_browser++;
    }
    if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']),’windows’)>0) {
    $mobile_browser=0;
    }

  61. Thanks for any other informative site. The place else may
    just I get that type of information written in such a perfect manner?
    I have a venture that I am just now running on,
    and I’ve been on the glance out for such info.

  62. rohit says:

    thank you very much
    which work i can`t do in whole day your advice it do in one minut
    thanks yar
    dil se

  63. Wayne says:

    Wow, fantastic blog layout! How long have you been blogging for?
    you make blogging look easy. The overall look of your web site
    is wonderful, as well as the content!

Leave a Reply

Copyright © 2013 Silicon Station. All rights reserved.