![]() |
I tried with this line (as suggested):
<? include($_SERVER['DOCUMENT_ROOT']."test.inc"); ?> but I still get these errors: Warning: main(/Library/WebServer/Documentstest.inc): failed to open stream: No such file or directory in /Users/memoryman/Sites/test/index.php on line 1 Warning: main(): Failed opening '/Library/WebServer/Documentstest.inc' for inclusion (include_path='.:/usr/lib/php') in /Users/memoryman/Sites/test/index.php on line 1 I am aware of the fact that this $DOCUMENT_ROOT thing was changed some time ago but since everything seemed to be working on my site I never took the time to change everything... I will do that sometimes, even though it will take me a while with all the pages... I just went by the old rule "if it ain't broken, don't fix it" ;-) The fact is right now I just would like to work locally on my mac on some files that DO work remotely. A month ago I had a PC and I had no problem working offline with Apache and PHP... Mac's are supposed to be better, why can't I make it work? I just want a folder to be considered the document root and then I'll throw everything in that folder and that should work, right? |
Quote:
All I want is work on my HD as if it was my remote server. There's got to be a way! I was doing it on my PC, you guys are not gonna tell me I bought a Mac after 10 years of PC and I can't do this, are you? ;-) |
Two Items >>
If in your Sites directory you have a php page with the line: echo $_SERVER['Document_ROOT']; it will show you : /Library/WebServer/Documents Your test.inc would have to be located there, not in your Sites directory. Like you, I develop and test php on OS X because of its time-saving advantages. You don't have to change the path of includes - just use relative paths as you would for any other file. For testing, be sure that the path in the browser address bar begins with http://127.0.0.1/~you/ ... I have not always succeeded with http://localhost/ On a somewhat different but related topic, .inc files are subject to security risks, and it's better to use a .php extension. See the section "Include Files" here: http://www.developer.com/lang/article.php/922871 I hope you find this helpful. |
Quote:
This is evident from the error message where it complains about not finding a file called "Documentstest.inc" |
As I wrote:
Quote:
|
Quote:
I understand exactly what you are saying but using relative paths would still mean for me to change all my files (which have already been created years ago with absolute $DOCUMENT_ROOT paths) and which, as you understood, is exactly what I am trying to avoid. So I guess the next logical step would be to change the root in fttpd.conf to my user's site folder and then work from there, do you agree or are there any negative implications in that? By the way the reason I did not use relative paths in the past is that in some instances I remember using include("../this.inc"); would not work, I don't remember when and why... Also thanks for pointing out that there is a difference between http://localhost/~myusername and http://127.0.0.1/~myusername - I was totally unaware of that, and my browser actually often self-redirects itself to http://myusername.local (without the ~) which seems to be even more convenient but I guess is still not as good as the IP format, right? Thanks for that other link too, I will check that out when I have some time... Anyway, so far I have used .inc only for text includes and .php for code includes. |
Don't neglect the configuration settings you can specify in php.ini
And if you haven't already done so, stop everything and go and read all of the documentation on configuration and includes at www.php.net |
Ok I am getting crazy over this, can't seem to figure it out...
I have changed the two instances of the document root settings in httpd.conf to Library/WebServer/Documents/Sites I have created a folder called Sites inside the Documents and a simple include now works, except my scripts still won't work... Now I get a call to undefined function error as soon as I start any script with any function (which I repeat are all easy functions that work perfectly when launched remotely on my server)... THERE HAS GOT TO BE A WAY TO MAKE THIS WORK EASILY!!!!!!!! |
Ann undefined function error usually means that your includes are incorrect. Try adding in a statement to print out the path that is being included, and then go and look in that file to see if the troublesome function is in that file.
|
Quote:
Quote:
PHP Code:
PHP Code:
I want to thank you ALL for taking the time to helping me out on this issue. I do REALLY appreciate your help, time and effort. You are great people with a great heart. Now that this is solved, I will have to change all these instances of that variable in houndred of files, which brings me to my next question about what GREP softwares are available for Mac OSX to batch this process effectively. In order to keep these forums nice and clean I posted this question in a more appropriate section of the forums and I will post the address here if any of you would be so kind and provide me with any hint you might have about this. Thank you very much once again. Here is the link: http://forums.macosxhints.com/showth...596#post125596 |
| All times are GMT -5. The time now is 05:46 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.