SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    Orlando, FL
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting "undefined variable" error when using an include?

    So I have a header.php file that I include at the top of my sites, that includes the navigation as well as a few global variables, like $loggedinusername , $pagename , etc.

    The weird issue I'm having is, I just transferred to a new server, and now the variables that I'm trying to call in the page itself (that are defined in the header.php file) are giving me "undefined variable" errors. The header.php file IS including for sure because I can see the navigation and such, but for some reason the page won't get the variables from the included file.

    Is there some kind of setting in php that could be causing this?

  2. #2
    SitePoint Evangelist simshaun's Avatar
    Join Date
    Apr 2008
    Location
    North Carolina
    Posts
    438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried a basic test to see if it is in fact the server, and not a mistake with your code that your other server just wasnt warning you about?

    include.php
    PHP Code:
    $var 'hello '
    runme.php
    PHP Code:
    include('include.php');
    echo 
    $var 'world'
    I'm about 99% sure its a mistake in your code. Reason being, your other server was probably set up not to display notices (or error_reporting was completely turned off), whereas your new server is set to display notices.


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
  •