Jump to content

HELP PLS! Newbie: fopen() error?


Pipes

Recommended Posts

Hello: I'm a complete novice trying to split a file of quotations into quotes and authors (it's a .txt file). I've written this short simple script but i'm getting an error message.

[code]$quotestxt = '$DOCUMENT_ROOT/quotes.txt';
$quotes_file = fopen($quotestxt, 'r+');
while (fread($quotes_file, 1024)) {
$pattern = '^[\"]';
$quote_roster = preg_match($pattern, $quotes_file);
print_r($quote_roster);
}
[/code]
Th error message is telling me: Parse error: parse error, unexpected T_VARIABLE in C:\XXXX\separate_quotes_from_authors.php on line 15

can anyone tell me what I should looking for? i've tried the manual, but I can't seem to help myself. It's driving me mad!

any help appreciated!
Pipes
Link to comment
Share on other sites

Thanks Ken: sorry should have mentioned line 15 is the one that begins
$quotestxt = '$DOCUMENT_ROOT/quotes.txt';

I have now changed this to double quotes, but the problem persists.

The location and path is correct (I created a short variable name for the server path above this code.) so I don't know what variable problems to be looking for??

Thanks for trying to help.

best, Andy
Link to comment
Share on other sites

Use the full url of the document_root

example

$quotestxt = "folder_name/quotes.txt";

[code]
<?php
$quotestxt = "$DOCUMENT_ROOT/quotes.txt";
$quotes_file = fopen($quotestxt, 'r+');
while (fread($quotes_file, 1024)) {
$pattern = '^[\"]';
$quote_roster = preg_match($pattern, $quotes_file);
print_r($quote_roster);
}
?>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.