SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru JoePrice's Avatar
    Join Date
    Jan 2002
    Location
    UK
    Posts
    673
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Undefined Index Help

    Hi Chappies

    I've got a php page where at the top i'm declaring a load of variables that obtain their data from $http_post_vars

    However, when the page is first loaded there's no post data to obtain and therefore i'm getting the error:

    Notice: Undefined index: question1 in ../../location.././/etc/ on line 9

    The post data comes when a form on the page is submitted and the page is refreshed.

    So my question is, how can i get rid of this error that appears at the top of my page when the page first loads?

    Any suggestions most greatfully appreciated.

  2. #2
    SitePoint Addict Resident Evil's Avatar
    Join Date
    May 2003
    Location
    Barrow
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hoi Buzz, son, used to play pa with ya in npu

    PHP Code:
    if(!isset($http_post_vars)) {

    //do **** all

    dno just an idea :P

  3. #3
    SitePoint Guru JoePrice's Avatar
    Join Date
    Jan 2002
    Location
    UK
    Posts
    673
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alritey mate
    you beauty, worked a treat

    What was your pa nick?

  4. #4
    SitePoint Addict Resident Evil's Avatar
    Join Date
    May 2003
    Location
    Barrow
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    coza

  5. #5
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $foo = (isset($_POST['foo'])) ? $_POST['foo'] : ''
    $foo would either contain the value from the form, or if the form wasn't sent, an empty string.

  6. #6
    SitePoint Guru JoePrice's Avatar
    Join Date
    Jan 2002
    Location
    UK
    Posts
    673
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    great thanks for the suggestions guys!


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
  •