SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy undefined index error

    hello frnds this is my code and dont know why this Undefined index: admin_name in C:\wamp\www\advance php\login\showadmin.php on line 15 pops up i am nt able to fix it please help me out

    PHP Code:
    <?php 
    var_dump
    ($_COOKIE);
    if(isset(
    $_COOKIE['s']))
    {
    require_once 
    'connect.php';
        
    $query=mysql_query("SELECT 'admin_name.admin_name','admin_name.admin_lastname','admin_name.admin_creattime',
            'admin_detail.admin_pass','admin_detail.admin_phone','admin_detail.admin_email','admin_detail.admin_gender'
    FROM admin_name,admin_detail "
    );
        if(!
    $query)
        {
            die(
    'nt good fail to select'.mysql_error());
        }
        else{
            while(
    $row=mysql_fetch_row($query)):
                 
    $name    $row['admin_name'];
                   
    $last     =$row['admin_lastname'];
                  
    $acctime    =$row['admin_creattime'];
                 
    $pass   =$row['admin_pass'];
                 
    $phone   =$row['admin_phone'];
                 
    $mail   =$row['admin_email'];
                 
    $gen   =$row['admin_gender'];
                 echo 
    $name." ".$last." ".$acctime." ".$pass." ".$phone." ".$mail." ".$gen;
                endwhile;
     }
    }
    else{
        echo 
    "sorry";
    }
     
    ?>
    Last edited by cpradio; Jun 28, 2013 at 10:33. Reason: added php tags

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,157
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    First off, your query looks wrong, I believe it should be
    PHP Code:
    "SELECT admin_name.admin_name, admin_name.admin_lastname, admin_name.admin_creattime,
            admin_detail.admin_pass, admin_detail.admin_phone, admin_detail.admin_email, admin_detail.admin_gender
    FROM admin_name,admin_detail " 
    Then to figure out how to access it, write the following line within your while loop
    PHP Code:
    var_dump($row); 
    You will either see that you need to reference the column names as $row['admin_name.admin_name'] or you may still be able to use $row['admin_name'] (I think the later will still be accurate).

  3. #3
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanku frnd it helped me when i use index number at the place of $name = $row['admin_name']; than it works but if i do $name = $row['admin_name'] this again give the same error

  4. #4
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,032
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    Something that you need to keep in mind is that the mysql_* extension is deprecated as of version 5.5 of PHP, you should really be migrating over to either the mysqli_* extension or to PDO
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  5. #5
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,157
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by php learner View Post
    thanku frnd it helped me when i use index number at the place of $name = $row['admin_name']; than it works but if i do $name = $row['admin_name'] this again give the same error
    Did you update your query and perform the var_dump as I stated? The var_dump will give you an output that tells you the key name to use.


Bookmarks

Posting Permissions

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