SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I fix these errors???

    I put full error reporting on http://www.geoworld.org/na/usa/al/ so you can see what's going on. It's extremely confusing because that same page gets different errors locally. I THINK I've republished all relevant local pages, so what's online should be exactly what I have on my computer.

    At any rate, the following errors appear near the top of the page:

    PHP Code:
    NoticeUndefined variablemykind in /home/world/public_html/a1/inc/head/a1.php on line 84

    Notice
    Undefined variablemykind in /home/world/public_html/a1/inc/head/a1.php on line 87

    Notice
    Undefined variablemykind in /home/world/public_html/a1/inc/head/a1.php on line 90

    Notice
    Undefined variablemykind in /home/world/public_html/a1/inc/head/a1.php on line 93

    Notice
    Undefined variablemykind in /home/world/public_html/a1/inc/head/a1.php on line 96

    Notice
    Undefined indexIDParentReg in /home/world/public_html/a1/inc/head/a1.php on line 182 
    The $mykind errors don't seem to be causing any problems, so I can probably ignore them. But the last error does cause a problem. So how do I define it?

    This is what it looks like in my HTML:

    PHP Code:
    echo ('<link href="/a1/css/world.css" rel="stylesheet" type="text/css" />
     <link href="/a1/css/na.css" rel="stylesheet" type="text/css" />
     <link href="/a1/css/na/' 
    $data_details['IDParentReg'] . '.css"   rel="stylesheet" type="text/css" />');
     break; 
    On my local page, I get similar errors - but they refer to different pages!

    PHP Code:
    NoticeUndefined variablemykind in C:\sites\GeoWorld\a1\inc\body\a1.php on line 17

    Notice
    : Use of undefined constant IDParent assumed 'IDParent' in C:\sites\GeoWorld\a1\inc\body\stahom.php on line 3

    Notice
    : Use of undefined constant IDParent assumed 'IDParent' in C:\sites\GeoWorld\a1\inc\body\stahom.php on line 4 
    Moreover, the IDParent error doesn't seem to cause any problems; the function that depends on it works locally.

    IDParent works on www.geoworld.org/eur/fra/, which does give me one clue. My STATE links use a more complicated ID than the national links. France is fra, while Alabama is us-al. And I've had to use a variety of scripts to transform us-al into al where necessary.

    But, again, if it's working locally, why isn't working online??? I don't think it's a database problem, because it appears to relate directly to my HTML, queries, etc.

    Any tips?

  2. #2
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Another clue...this variable from the same page appears to be working:

    PHP Code:
    <?php
    switch ($data_details['IDArea']) {
    case 
    'us-ak':
    $Counties='Boroughs';
    break;
    IDParentReg and IdArea are found in the same database table - though IDArea is also the name of a field in several other tables. So maybe there's something wrong witih my query. (Both the query and the page the problem is on are included into the main page.)

  3. #3
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You get these errors when you haven't checked that a variable or array element exists.
    the correct way to program this would be
    if(isset($mykind)) { echo $mykind; }
    wherever you need to echo out the result. Likewise with the array values.
    Note as well that this isn't a serious error and you can turn off reporting of PHP notice errors, but they are there to promote good coding practice.

  4. #4
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rossriley
    You get these errors when you haven't checked that a variable or array element exists.
    the correct way to program this would be
    if(isset($mykind)) { echo $mykind; }
    wherever you need to echo out the result.
    So instead of writing <?php echo "$mycode" ?> I should write <?php if(isset($mykind)) { echo $mykind; } ?> ?

    And how should I write this?:

    PHP Code:
    <?php
    switch ($mykind)
    {
       case 
    'pla':
    Likewise with the array values.
    So IDParentReg should work if I just rewrite it? How would I rewrite this?:

    PHP Code:
    <link href="/a1/css/na/' . $data_details['IDParentReg'] . '.css"   rel="stylesheet" type="text/css" />'); 
    In the meantime, the plot just got thicker. I just discovered that the "weather in the capital" feature works on the Alaska page - www.geoworld.org/na/usa/ak/ - but not on the Alabama page. It uses a variable similar to IDParentReg, but I can't understand why it should work on one page and not the other. They both use the same queries and database.

    Thanks.

  5. #5
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oops - ignore my last post. It turns out that error was caused by error reporting.


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
  •