Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > PHP Include Folder???

PHP Include Folder???
Thread Tools
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status: Offline
Reply With Quote
Jan 29, 2003, 11:58 AM
 
i think the database swallowed your question, wanna post it again?
"Have sharp knives. Be creative. Cook to music" ~ maxelson
     
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
Jan 30, 2003, 10:50 PM
 
This is weird. OK anyway I downloaded this stats software that uses php/mysql to track hits to many different sites. Its a nice clean efficient tracker. Instead of including huge chunks of php and javascript in each page i want to track, I just include one short line of PHP and thats all it needs to track everything. The problem is I can't get it to work. It uses the php function include to call a document by its name only. They authors don't do english very well and would rather point to a FAQ than help me solve the problem. The problem is the php calls the script that records the data just by name, so i don't have to manually write a full path for every page on every site. BUT since this script isn't in every page on every site, it gives me an error that it coudln't include it. The options are to write out a full path on every page, OR, the better sounding solution, put the file that is included in every page into the "php includes folder" but what the hell is that? I tried putting an include statement in a php.ini file and that got me nowhere. I can't seem to find any clear documentation on just what it is that I need to do here. If you know about php please help me out.
     
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Jan 31, 2003, 02:39 AM
 
Originally posted by l008com:
This is weird. OK anyway I downloaded this stats software that uses php/mysql to track hits to many different sites. Its a nice clean efficient tracker. Instead of including huge chunks of php and javascript in each page i want to track, I just include one short line of PHP and thats all it needs to track everything. The problem is I can't get it to work. It uses the php function include to call a document by its name only. They authors don't do english very well and would rather point to a FAQ than help me solve the problem. The problem is the php calls the script that records the data just by name, so i don't have to manually write a full path for every page on every site. BUT since this script isn't in every page on every site, it gives me an error that it coudln't include it. The options are to write out a full path on every page, OR, the better sounding solution, put the file that is included in every page into the "php includes folder" but what the hell is that? I tried putting an include statement in a php.ini file and that got me nowhere. I can't seem to find any clear documentation on just what it is that I need to do here. If you know about php please help me out.
It would appear that you need to use the 'auto_prepend_file' directive within a php.ini file in order for this to work. In essence, it processes the file you specify and adds it to the start of the page you have requested. This should solve your problem. I've not tested this personally - never needed a php.ini file on my local test network - but let me know if it works.

If you need a php.ini file to refer to, download the source from php.net, decompress the folder and look for a file within the distribution folder called 'php.ini-dist' which will have a default config for you to look at.
Computer thez nohhh...
     
Mac Elite
Join Date: Aug 2000
Location: Minneapolis, MN
Status: Offline
Reply With Quote
Jan 31, 2003, 09:40 AM
 
The other option is to include a variable with your particular $serverpath that is global, then just add that to your 'line of PHP code.' While it still adds some, its not as bad as a full path to each item.
     
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
Jan 31, 2003, 05:20 PM
 
yeah but what about what the auther said? PHP includes folder? Is there a folder somehwere I can just drop a copy of this file into to make it work?
     
Dedicated MacNNer
Join Date: Jan 2001
Location: Meida, PA USA
Status: Offline
Reply With Quote
Feb 1, 2003, 02:31 PM
 
There is this folder:
/System/Library/PHP/

Which I believe acts as the PHP include folder. You can't add you file there through the Finder though since the System folder is suppost to be pure. using php's info() on a recent server install i also see this as an include_path:

/usr/lib/php/

Try these out. I also know of a hack-ish way where you can insert a few lines in the httpd.conf to set PHP's include folder to where ever you want, but I'll recommened it only as a last resort.
~ Mike
--
Personal Site: MikeZornek.com
Other Interests: WebDevWiki.com
     
Fresh-Faced Recruit
Join Date: Oct 2002
Location: St. Louis, MO
Status: Offline
Reply With Quote
Feb 1, 2003, 10:48 PM
 
Sounds like you need to set a default include path. If your are using apache as the webserver, you could put this line into a .htaccess file in your root web directory:

Code:
php_value include_path ".:/path/to/script/to/include/:/some/other/path"
Put that all on one line, btw.

What it does is add default search directories for scripts that are included. when you include something with the standard include("blah.php"); function, it will check all the directories you specify in that line. If you have lots of included files in one or two locations, just add those locations to the line above, seperated by colons (the example above has the . directory added too, so it will check the current directory first). I find it very helpful, because you don't have to worry about paths in the individual documents.

Peace,
sam
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:07 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2