Error after loading PHP file on WAMP

Discussion in 'PHP' started by DesignBytes, Jun 6, 2013.

  1. #1
    Hi,
    I hope this is the write forum. I have created a site on my local WAMP server and tried to open the php page so I can edit it in real time. Got the following warnings.

    ( ! ) Warning: constant() [<a href='function.constant'>function.constant</a>]: Couldn't find constant PHP_DIR in C:\wamp\www\site\mytpl\index.php on line 10

    ( ! ) Warning: chdir() [<a href='function.chdir'>function.chdir</a>]: Invalid argument (errno 22) in C:\wamp\www\site\mytpl\index.php on line 10


    this is what is written on line 10 in the php code
    chdir(constant("PHP_DIR")) or die("Fatal Runtime Error.");?>

    Can someone guide me in the correct direction ?
    WAMP icon is GREEN and running fine.phpmyadmin also ran fine
     
    DesignBytes, Jun 6, 2013 IP
  2. HuggyStudios

    HuggyStudios Well-Known Member

    Messages:
    724
    Likes Received:
    20
    Best Answers:
    26
    Trophy Points:
    165
    #2
    Your server is working fine that isn't the problem. Post all of the code from index.php and any other files which are being included for me to be able to help more.
     
    HuggyStudios, Jun 6, 2013 IP
  3. DesignBytes

    DesignBytes Notable Member

    Messages:
    1,237
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    200
    #3
    Hi,
    Thanks for the help. Its actually a PTC script ( Clix Script from Incentive scripts ) , and there are a lot of files but I will copy here the index.html for now.

    http://pastebin.com/wvuUY6bn

    As I see its using some masterpage or iframe kind of concept to read in other files as header, footer and nav and these 3 files are in another folder than this index file, does it changes directories for this ?

    Thanks for any help.
     
    DesignBytes, Jun 6, 2013 IP
  4. Marcel Preda

    Marcel Preda Member

    Messages:
    21
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    43
    #4
    Hi there,

    If you said that the file was provide with a bunch of other scripts there probable PHP_DIR constant should be defined in some other PHP file.
    Look for filenames like config.php, globals.php, settings.php etc..
    And here you should probable set PHP_DIR .
    Also, looking at the code on that link looks like you will need to put some include() or required() to load some other files, unless your file is not wrapped by some other main PHP script.

    BR,
    Marcel
     
    Marcel Preda, Jun 6, 2013 IP
  5. HuggyStudios

    HuggyStudios Well-Known Member

    Messages:
    724
    Likes Received:
    20
    Best Answers:
    26
    Trophy Points:
    165
    #5
    To remove the error would be simple just add after line 9 (the comments)
    
    define('PHP_DIR', getcwd());
    
    PHP:
    As you haven't supplied me with the other classes and methods there's not really much that I can do. Please post the other classes and then I can help some more.
     
    HuggyStudios, Jun 6, 2013 IP