Zepx Posted November 13, 2009 Share Posted November 13, 2009 Hi, I'm facing a very weird problem. First I would like to explain what is going on. 1. I have a first.php script that does a require('settings.php'); and another second.php script that does a require_once('settings.php'); 2. The idea here is to load settings.php and output the variables inside of it. It also has 3 functions. The problem is when both of first.php and second.php script loads together, the settings.php gets loaded once, but I can't echo and variables from settings.php from my second.php script. I had onced tried both files using required() but I got an error saying that I'm not allowed to redeclared the functions that were already declared. So I knew I had to use require_once(). But it's not working like how I want. For those who can't get what I mean, please check out this two links, http://zepx.co.cc -- The homepage, if you look at the sidebar, under New Links, you should see that the output works fine. http://zepx.co.cc/links/ -- Now, look at the sidebar, it's showing errors. It says that I'm using File() but there was no parameter in it, that is because I took the parameter from settings.php, which resulted an empty string. Also, as you can see at http://zepx.co.cc/links/ , the page has 2 php scripts, one was loaded in the content, and the other in the sidebar. I'm not sure if my explaination was clear. If it's not, I'll try to restructure my sentences. Regards, Zepx Link to comment https://forums.phpfreaks.com/topic/181398-require_once/ Share on other sites More sharing options...
rlelek Posted November 13, 2009 Share Posted November 13, 2009 Hello! I Get a 404 for http://zepx.co.cc/links/ I, along with most of the PHP programmers I know, will always use require_once(); We usually use that simply because if it is loaded, you do not want an error returned if it was already included. Maybe try switch both to require_once(); and see if your problem still exists. If it does, see if you can get the webpage working because a live example is like a picture...worth 1000 words! Ryan Link to comment https://forums.phpfreaks.com/topic/181398-require_once/#findComment-956896 Share on other sites More sharing options...
Zepx Posted November 13, 2009 Author Share Posted November 13, 2009 sorry for the trouble, please check again the link. I've forgotten that I've made the link private. Link to comment https://forums.phpfreaks.com/topic/181398-require_once/#findComment-956906 Share on other sites More sharing options...
rlelek Posted November 16, 2009 Share Posted November 16, 2009 I don't see any errors on the page. Is everything good now? Link to comment https://forums.phpfreaks.com/topic/181398-require_once/#findComment-958444 Share on other sites More sharing options...
Zepx Posted November 16, 2009 Author Share Posted November 16, 2009 yep. thanks, I found out the problem wasn't related to require_once. It was because of variable's scope. Link to comment https://forums.phpfreaks.com/topic/181398-require_once/#findComment-958543 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.