0
votes

Index.php

<?php include './include.php'; ?>
<html> Page data
<?php echo $c5t_output; ?>
 </html>

include.php

<?php

    /** 
     * GentleSource Comment Script
     * 
     */

    define('C5T_ROOT', '/comment_script_2.1.2/');
    include C5T_ROOT . 'comment.php'; 


    ?>

I get this below error 000webhost.com free server when i load the script on a page say index.php but it works perfectly on my local xampp server, even though the file is in the right location with the right files names.

Warning: include() [function.include]: Failed opening '/comment_script_2.1.2/comment.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/a5962782/public_html/include.php on line 9

1
Some path error man, double check it. - DontVoteMeDown
I wonder if your constant should be relative? In which case, it should be './comment_script_2.1.2/', i.e. prefixed with a dot. As it stands, it expects that folder to be at the root of the filing system, which you may have on your local machine - if so it's in the wrong place - but this is not possible on a shared hosting provider. - halfer

1 Answers

0
votes

From: http://php.net/manual/en/function.include.php

If a path is defined — whether absolute (starting with a drive letter or \ on Windows, or / on Unix/Linux systems) or relative to the current directory (starting with . or ..) — the include_path will be ignored altogether. For example, if a filename begins with ../, the parser will look in the parent directory to find the requested file.

You have defined an absolute path in your include. Remove the / and it should work.

define('C5T_ROOT', 'comment_script_2.1.2/');
include C5T_ROOT . 'comment.php'; 

This will make the include look in your include path, which has your current directory (.) in it. So ./comment_script_2.1.2/comment.php will be picked up.