Jump to content

Recommended Posts

Hi,

 

I am fairly new to php and seem to be getting this common error...

 

"Notice: Undefined index: action in C:\wamp\www\Veetees\cart\cart.php on line 8"

 

When clicking on a link on one php page, to take me to a page called cart.php it shows this error message.

 

The script it is trying to run is:

 

<?php

session_start();

 

require "../connect.php";

 

$cart = $_SESSION['cart'];

$action = $_GET['action'];

 

Seems to not like the $action variable but I don't understand what undefined index means?? any help would be appreciated...

 

Many thanks.

Link to comment
https://forums.phpfreaks.com/topic/148919-undefined-index-problem/
Share on other sites

The index is the key with which you access an element in an array. In your case of $_GET['action'] you are trying to retrieve the index called action on the array called $_GET.

 

In your case that index doesn't exist and you'll get a notice from PHP. You can use isset or key_exists to check this.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.