Jump to content


Photo

HELP PLS! Newbie: fopen() error?


  • Please log in to reply
3 replies to this topic

#1 Pipes

Pipes
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 06 October 2006 - 07:40 PM

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.

$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);
}
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


#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 06 October 2006 - 09:15 PM

Which is line 15?

Also, you want to use double quotes instead of single quotes on this line:
<?php $quotestxt = '$DOCUMENT_ROOT/quotes.txt'; ?>

Ken

#3 Pipes

Pipes
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 07 October 2006 - 10:48 AM

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


#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 07 October 2006 - 01:45 PM

Use the full url of the document_root

example

$quotestxt = "folder_name/quotes.txt";

<?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);
}
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users