seany123 Posted November 5, 2011 Share Posted November 5, 2011 As the title above says im trying to use this code: require_once("http://www.example.com/connect_file.php"); its giving this error: Warning: mysql_query() [function.mysql-query]: Access denied for user 'username'@'localhost' (using password: NO) in /template/header.php on line 56 if i was to just use this code it works fine: require_once("./connect_file.php"); Just incase it makes a difference, im testing this on index.php, however the codes above are not inside index.php, instead they are inside my /templates/header.php file which is included at the top of index.php any ideas? Quote Link to comment Share on other sites More sharing options...
xyph Posted November 5, 2011 Share Posted November 5, 2011 When requesting it through the HTTP protocol, the PHP engine will parse it before outputting. When requesting it through the file system, you will get the raw contents of the file. Quote Link to comment Share on other sites More sharing options...
seany123 Posted November 5, 2011 Author Share Posted November 5, 2011 Okay i think i have solved the problem, <?php define('__ROOT__', dirname(dirname(__FILE__))); require_once(__ROOT__.'/connect_file.php'); ?> this seems to work. any better suggestions or improvements? Quote Link to comment Share on other sites More sharing options...
xyph Posted November 6, 2011 Share Posted November 6, 2011 Using the absolute path is a great method Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.