Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    undefined index error

    PHP Code:
    could u help me with this code...

    it gives me 
    "Notice: Undefined index: action in C:\wamp\www\...\posts.php on line 9"



    include($_SERVER['DOCUMENT_ROOT'].'tumblelog/models/post.php');
     
    $action $_GET['action'];

     switch(
    $action) {
     
       case 
    "show":
             
    $post=find_post(2);
             echo 
    "This is the show action";
         break; 
                     }


    Thanks in advance 

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    $action = $_GET['action'];

    switch($action) {

    case "show":
    $post=find_post(2);
    echo "This is the show action";
    break;
    }
    Change the above to
    PHP Code:
    if(isset($_GET['action'])){
     
    $action $_GET['action'];

     switch(
    $action) {
     
       case 
    "show":
             
    $post=find_post(2);
             echo 
    "This is the show action";
         break; 
                     } 

    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    eatit007 (11-27-2010)

  • #3
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks bro..but I solved it .
    Used this code...

    PHP Code:
     include($_SERVER['DOCUMENT_ROOT'].'tumblelog/models/post.php');
    if (isset(
    $_GET["action"]))
        
    $action $_GET["action"];
    else 
    $action="";
                     } 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •