For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > March 2004 > Error processing text ...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Error processing text ...
Adam Rumpke

2004-03-26, 11:12 pm

Can some please help me. I want this script to save my textbox input
from the form to the file about.txt ... For some reason it wont work
and I am .

//////////////////////////////////////
saveAbout.php
//////////////////////////////////////

<?php

$fp = @fopen("about.txt", "rb") or die("Couldn't open file");
$data = fread($fp, filesize($fp));

while(!feof($fp))
{
$data .= fgets($fp, 1024);
}

fclose($fp);

$values = explode("\r\n", $data);

echo . $values[0] . " " . $values[1] . "<br>";

?>

//////////////////////////////////////
formAbout.html
//////////////////////////////////////

<html>
<head>
<title> About Us Editor </title>
</head>
<body bgcolor="#ffffff">
<form action="saveAbout.php" method="post">
Edit the topic in the box below :
<p>&nbsp;&nbsp;&nbsp; <textarea rows="15" name="S1" cols="57">
</textarea>
<br>
<br>
<input type="submit" value="Save Data >>">
</p>
</form>
</body>
</html>

//////////////////////////////////////
Thanks in advance

- Adam
Matt Garrish

2004-03-26, 11:12 pm


"Adam Rumpke" <goldstonrumpke@hotmail.com> wrote in message
news:13c3ff37.0403220212.5fecec49@posting.google.com...
> Can some please help me.
>


Please stop cross-posting to inappropriate groups. I've tried to be nice so
far, but PHP has nothing to do with Perl and vice-versa. Also note that php
is *not* a top level usenet group, hence there will never be a
"php.general".

Matt


Jürgen Exner

2004-03-26, 11:12 pm

Adam Rumpke wrote:
> Can some please help me. I want this script to save my textbox input
> from the form to the file about.txt ... For some reason it wont work
> and I am .


Well, it is full of syntax errors to begin with.
Not to mention that you are missing

use strict;
use warnings;

> $fp = @fopen("about.txt", "rb") or die("Couldn't open file");


If you want to index an array you should use square brackets.
If the @fopen("about.txt", "rb") is meant to open a file about.txt, then
maybe you meant something like
open (FH, ">about.txt");
However it is hard to tell what you are trying to accomplish because the
syntax only very vaguly resembles Perl.

> $data = fread($fp, filesize($fp));


Where is fread() defined?
Did you mean read() (unlikely) or simply <FH>?

> while(!feof($fp))


Where is feof() defined?

[rest of bogus 'code' snipped]

Well, you know, you really should get a book about learning Perl,
familiarize yourself with the basic syntax, and try some programs on the
"Hello World" level before venturing into more elaborate areas. Your program
is so hopelessly broken, I would just throw it away and start from scratch
anew.

jue


muis

2004-03-26, 11:12 pm

> Well, you know, you really should get a book about learning Perl,
> familiarize yourself with the basic syntax, and try some programs on the
> "Hello World" level before venturing into more elaborate areas. Your

program
> is so hopelessly broken, I would just throw it away and start from scratch


You do realize he's asking a PHP question right? He prolly crossposted to
your perl group by accident.


Adam Rumpke

2004-03-26, 11:13 pm

Actually the code seems to work -> I tried it on Linux and it worked
once I chmod 777 the files. Thanks for your help though. Would anyone
know how to work around the chmod issue on Windows? Seems like this
issue is windows :)

Thanks

- Adam
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com