aarbrouk Posted March 11, 2009 Share Posted March 11, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/148919-undefined-index-problem/ Share on other sites More sharing options...
jcombs_31 Posted March 11, 2009 Share Posted March 11, 2009 Means you are probably not passing the variable $action in the url. Quote Link to comment https://forums.phpfreaks.com/topic/148919-undefined-index-problem/#findComment-781944 Share on other sites More sharing options...
Daniel0 Posted March 11, 2009 Share Posted March 11, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/148919-undefined-index-problem/#findComment-781945 Share on other sites More sharing options...
aarbrouk Posted March 11, 2009 Author Share Posted March 11, 2009 thanks for your help, problem solved, I used an isset statement to get rid of the problem that i wasn't passing anything through... Many thanks. Quote Link to comment https://forums.phpfreaks.com/topic/148919-undefined-index-problem/#findComment-781989 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.