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? Link to comment https://forums.phpfreaks.com/topic/250530-error-using-require_oncehttpwwwexamplecomconnect_filephp/ 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. Link to comment https://forums.phpfreaks.com/topic/250530-error-using-require_oncehttpwwwexamplecomconnect_filephp/#findComment-1285355 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? Link to comment https://forums.phpfreaks.com/topic/250530-error-using-require_oncehttpwwwexamplecomconnect_filephp/#findComment-1285358 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 Link to comment https://forums.phpfreaks.com/topic/250530-error-using-require_oncehttpwwwexamplecomconnect_filephp/#findComment-1285375 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.