#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    28
    Rep Power
    0

    Use of undefined constant


    So I transferred my code from my Windows computer, which runs XAMPP as a webserver, to my Raspberry Pi for a local webhost. The Raspberry Pi runs Apache 2 and the PHP 5.4.4-14 which probably is the latest version since I installed it yesterday. So everything runs fine on my Windows computer, but when I put it on my RPi I get messages "Notice: Use of undefined constant URL - assumed 'URL' in /var/www/views/header.php on line 8" and the defined constant URL is defined in my paths.php file which contains paths ofcourse. For the moment is that only the constant URL. The constant that I defined in the paths file is undefined when using it in my views object. I'm using a MVC object oriented framework to work with. But why is this happening on my Raspberry Pi and not on my Windows, I looked up some stuff and 3 years ago there was a post on Stackoverflow just like this but there was no answer. No file has been modified when transferring this.

    config/paths.php:
    PHP Code:
    define('URL''http://127.0.0.1/');
    echo 
    'PATHS URL: ' URL
    This outputs "PATHS URL: http://127.0.0.1/", so the constant is defined.

    views/header.php:
    PHP Code:
    ob_start();
    echo 
    '<!DOCTYPE html>';
    echo 
    '<html>';
    echo 
    '<head>';
        echo 
    '<title>Title</title>';
        echo 
    '<link rel="stylesheet" href="' URL '/public/css/style.css" type="text/css">';
        echo 
    '<script src="' URL 'public/js/jquery-1.9.1.min.js"></script>';
        echo 
    '<script src="' URL 'public/js/init.js"></script>';
    echo 
    '</head>';
    echo 
    '<body>';
    echo 
    '<div id="container">';
    echo 
    '<div id="header">';
        echo 
    '<span><a href="' URL 'index">Home</a></span>';
        echo 
    '<span><a href="' URL 'help">Help</a></span>';
        echo 
    '<span><a href="' URL 'error">Error</a></span>';
    echo 
    '</div>';
        echo 
    '<div id="content">'
    Outputs normally on Windows, not on Raspberry Pi. The constant URL seems to be outputting "URL".

    Has anyone ever got this before or does anyone know how to fix this?
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,056
    Rep Power
    9398
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    28
    Rep Power
    0
    Originally Posted by requinix
    What's the entire code for header.php?
    That is the entire code, it's basic because I made this in about an hour or so.
  6. #4
  7. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,907
    Rep Power
    6351
    So you're not including the paths.php inside header.php. That's the error.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    28
    Rep Power
    0
    Originally Posted by ManiacDan
    So you're not including the paths.php inside header.php. That's the error.
    I'm not stupid, it is included in another file. I'm using an MVC structure and it works on Windows XAMPP.
  10. #6
  11. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,907
    Rep Power
    6351
    That is the entire code, it's basic because I made this in about an hour or so.
    That code contains no include(). You were asked if it's the entire code and you said yes. Therefore, the lack of an include is why code in other files isn't executing. If this is NOT the entire code, and for instance if you're using a complex unnamed MVC, maybe that's why. Since you're moving filesystems and docroots when you move to the Pi, I bet you're missing some files or paths or something. Turn on errors and check to see if there are error logs on the malfunctioning device.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,987
    Rep Power
    375
    Originally Posted by Dreeass
    I'm not stupid, it is included in another file. I'm using an MVC structure and it works on Windows XAMPP.
    no one is calling you stupid but just as it happens, people tend to forget the simplest things that are usually the cause of all the errors.

    He is trying to help you so please give him the courtesy he respects, after all he is not obliged to help you.
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    28
    Rep Power
    0
    Originally Posted by ManiacDan
    That code contains no include(). You were asked if it's the entire code and you said yes. Therefore, the lack of an include is why code in other files isn't executing. If this is NOT the entire code, and for instance if you're using a complex unnamed MVC, maybe that's why. Since you're moving filesystems and docroots when you move to the Pi, I bet you're missing some files or paths or something. Turn on errors and check to see if there are error logs on the malfunctioning device.
    For some reason it is now also happening on my Windows, I really have no idea what I have changed.

    Originally Posted by paulh1983
    no one is calling you stupid but just as it happens, people tend to forget the simplest things that are usually the cause of all the errors.

    He is trying to help you so please give him the courtesy he respects, after all he is not obliged to help you.
    It wasn't meant like that, American people probably won't understand what I mean.

    - I have found why it was showing the notices and why it was undefined, thanks for helping me all.
  16. #9
  17. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,907
    Rep Power
    6351
    Why was it broken?
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

IMN logo majestic logo threadwatch logo seochat tools logo