Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8655169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:57:46+00:00 2026-06-12T14:57:46+00:00

Possible Duplicate: PHP: “Notice: Undefined variable” and “Notice: Undefined index” This is strange but

  • 0

Possible Duplicate:
PHP: “Notice: Undefined variable” and “Notice: Undefined index”

This is strange but I am posting an input using the $_POST method which is below:

$c = count($_POST['gridValues']);

But the problem is that I am receiving an error stating:

Notice: Undefined index: gridValues in /web/stud/…./ on line 40
(which is line above)

How come I am receiving this error because the $_POST method is definitly correct?

Below is the whole code:

<?php

ini_set('session.gc_maxlifetime',12*60*60);
ini_set('session.gc_divisor', '1');
ini_set('session.gc_probability', '1');
ini_set('session.cookie_lifetime', '0');
require_once 'init.php'; 

 ini_set('display_errors',1); 
 error_reporting(E_ALL);


session_start();

?>

$i = 0;
$c = count($_POST['gridValues']);

for($i = 0;  $i < $c; $i++ ){

    switch ($_POST['gridValues'][$i]){

 case "3": 
    $selected_option = "A-C";
    break;

    case "4": 
    $selected_option = "A-D";
    break;

    case "5": 
    $selected_option = "A-E";
    break;
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:57:47+00:00Added an answer on June 12, 2026 at 2:57 pm

    You need to check if it is set first:

    <?php
    
    if(isset($_POST['gridValues'])) {
       $c = count($_POST['gridValues']);
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: PHP: “Notice: Undefined variable” and “Notice: Undefined index” This code shows warnings
Possible Duplicate: PHP: “Notice: Undefined variable” and “Notice: Undefined index” I have a member.php
Possible Duplicate: PHP: “Notice: Undefined variable” and “Notice: Undefined index” I upgrade/install PHP 5.4.4
Possible Duplicate: PHP: “Notice: Undefined variable” and “Notice: Undefined index” I am getting warnings.
Possible Duplicate: PHP: “Notice: Undefined variable” and “Notice: Undefined index” All of a sudden
Possible Duplicate: PHP: “Notice: Undefined variable” and “Notice: Undefined index” Recently turned on errors
Possible Duplicate: PHP: Notice: Undefined variable and Notice: Undefined index Reference - What does
Possible Duplicate: PHP: Notice: Undefined variable and Notice: Undefined index I want when I
Possible Duplicate: PHP: Notice: Undefined variable and Notice: Undefined index I am new to
Possible Duplicate: How to convert yyyy-MM-dd HH:mm:ss to “15th Apr 2010” using PHP I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.