burtybob Posted August 25, 2010 Share Posted August 25, 2010 Hi, I think I understand this but want to check. If I have files register, user.class and dbconnect. If both register and user.class use require_once dbconnect will the dbconnect still only be required on the first time? Ben Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted August 25, 2010 Share Posted August 25, 2010 Your question is a little confusing. But from what I gather of it. using require/require_once in either file all files or other. Depends on how your files are structured. The require aspect only pertains to the file, and the script thats in it. So if you require the file and place the line up top of your script to bring it in. It should connect to your DB as many times as the script needs, unless you close the connection to the DB after you run a query. That being the case, strip out any mysql_close() that you have below the require statement and put one at the bottom of the page you are pulling the script into. Also you can not require_once() the same file more than once in the same script it will just conflict and cause error. So if you pull 3 files together through one master files and all 3 need that required file to connect then put the connection file up top above all the others and make sure your not pulling in the required file again through the other scripts.. Yes I know this is a jumble. I appologize, but its the best way I can come up with describing it based on your initial question.. not knowing how your doing everything, no exact examples, just a simple generalized question that is a bit confusing to begin with makes answers harder to come up with. 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.