Re: fopen problem

From: Date: Fri, 22 Dec 2000 09:49:11 +0000
Subject: Re: fopen problem
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-31556@lists.php.net to get a copy of this message
Hi, I can't see anythinng wrong with your fputs statement. What's the exact errormessage you get? You can try this: $file = fopen($file,"w"); if($file) { fputs(...); } to make sure you actually open a file for writing. wieger > Hi all. > > I know this is probably a dumb question, but hey, I'm new! > > I am writing a script that I need to write a text file to save a "chapter" > submitted from a form... Basically it is one of those contributive story > things. > > Anyhow I am getting a parse error on line 62 which is where my fputs() > lives. What am I missing here? > > //create the new record > $sql = "INSERT INTO story1 (username,email,title,parent) VALUES > ('$username','$email','$title','$parent')"; > $thisrec = mysql_query($sql); > > //set the file name for the chapter text > $file = 'text.txt';// . $thisrec['sid'] . '.txt'; > > //update the record with the file name > $id = $thisrec['sid']; > $record = mysql_query("UPDATE story1 SET file='$file' WHERE > sid='$id'"); > > //Create the chapter's text file and open it for writing > $filehandle = fopen($file,"w"); > > // Write the file > fputs( $filehandle, $chaptext, strlen( $chaptext ) ); > > // and close it > fclose($filehandle); > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#31556) next »