Register | Login | |||||
Main
| Memberlist
| Active users
| Calendar
| Chat
| Online users Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album |
| |
0 users currently in Programming. |
User | Post |
Black Lord + Posts: 223/273 |
Originally posted by rubixcuber Or he could close the php script, put the next line, and then open it back up via . ?> <txta=text ROWS=100 COLS=100> $content </TEXTAREA> <? |
darkwitch Posts: 74/214 |
Ok, thanks
Im going to test it right away. And yes, I was talking about PHP . |
rubixcuber Posts: 345/356 |
Well, you didn't say but I'm going to assume PHP because of the $ prefix on variables and the ?>. If it's not PHP, most of it should still apply though.
First of all, fopen requires a second argument. You need to specify the mode you want to open the file in. Second, you have to tell fread how much data to read in. There are a couple ways to do this. You can check the file size and have fread read in that much data, or do a loop checking for the end of file and reading data if not at the end of the file yet. Third... this is the part that makes me wonder what language this is. In PHP fput is called fputs. And you pass the text as an argument. So this would be the way in PHP: fputs($file,$text); Also you need to close the file. Call fclose($file) when you are done using it. Here's my revised code: $file = fopen($filename ,'r'); //open file for reading $content = ""; while(!feof($file)){ //while not at end of file $content.=fread($file,1); //read one byte of the file } fclose($file); //close the file //I assume you want to print the next line. If PHP I think you need echo or some equivalent function <"txta=text ROWS=100 COLS=100">$content<""/TEXTAREA""> $inph=action VALUE=savefile> $inps=submit VALUE=\"Save File\"><""/TD""> if($action=blaablablabla){ fopen($file,'w');//open file for writing (this will erase the file is you want to append use a instead of w) fputs($file,$text); //write to file fclose($file); //close the file print" blabalablabal"; ?> Hope that helps a bit. |
darkwitch Posts: 67/214 |
Thanks Kailieann Now I know a way to post codes properly
But I still am confused with the codes I mentioned earlier |
Kailieann Posts: 519/808 |
With regards to the quotes..
< = < > = > |
darkwitch Posts: 50/214 |
Im not too good in ( fopen() fclose() fread() fwhatever() )
So anybody care to explain a little in deep how those work? Will this work: require blablabla; $file = fopen($filename); $content = fread($file); <"txta=text ROWS=100 COLS=100">$content<""/TEXTAREA""> $inph=action VALUE=savefile> $inps=submit VALUE=\"Save File\"><""/TD""> if($action=blaablablabla){ fput($file) = $text; print" blabalablabal"; ?> Please ignore the quotes, not adding them would do ugly things. Will that crap work (most likely not).I just want to know where I have errors to learn from my mistakes |