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.

Enjoy an ad free experience by logging in. Not a member yet? Register.

php include not opening .txt file

I'm inserting a simple, well-rated script from hotscripts to randomly display quotes which are stored in a .txt file. The .txt file is not being recognized by the php script. I think maybe there is more to the .txt file than just entering quotes onto the blank page, seperated by hitting [enter], but I'm not sure. Thanks for any help.

Since you have error reporting enabled and not suppressed, than you can see the message itself in the fopen call. That would be your issue, you simply cannot read the file. Causes can be: no file found on the path provided, and no permissions to read the file. The error will tell you the cause. If it says its not found, than the path is incorrect. If its in the same directory as this file, that indicates that this file is included into a different file on a differing path. You can set the path using __DIR__ . '/quotes.txt'; instead.

PHP Code:

header('HTTP/1.1 420 Enhance Your Calm');

Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

__FILE__ differs in that its the entire path including "this" script. Prior to. . . 5.2.x I think it was, __DIR__ hadn't existed, so we would use dirname(__FILE__) in its place.
It is IMO wise to always include or open files relative to "this" script. Since you can include "this" script in a different one with a different path, PHP takes its cwd as that of the executing script, not the inclusions. Using relatives from __DIR__ will always produce the correct paths.

PHP Code:

header('HTTP/1.1 420 Enhance Your Calm');

Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)