ia.studio Posted June 19, 2008 Share Posted June 19, 2008 Ok I don't know PHP, I just want to know if this file can create a HTML(text file) <?php $fileName = $_POST['fName'].".html"; $fileText = $_POST['fText']; $file=fopen($fileName,"a+"); fwrite($file,$fileText); echo "&resu=Created ".$fileName; ?> can you test and if possible fix it. Quote Link to comment https://forums.phpfreaks.com/topic/110932-need-help-file-check/ Share on other sites More sharing options...
ober Posted June 19, 2008 Share Posted June 19, 2008 You'll want to change "a+" to "w+" and make sure you use fclose($file); at the end. http://us2.php.net/fwrite Quote Link to comment https://forums.phpfreaks.com/topic/110932-need-help-file-check/#findComment-569092 Share on other sites More sharing options...
ia.studio Posted June 19, 2008 Author Share Posted June 19, 2008 <?php $fileName = $_POST['fName'].".html"; $fileText = $_POST['fText']; $file=fopen($fileName,"w+"); fwrite($file,$fileText); fclose($file) echo "&resu=Created ".$fileName; ?> I don't know PHP, I'm trying to use PHP to write files with actionscript 3.0 since actionscript 3.0 can't write files. Can you tell If it's oK Quote Link to comment https://forums.phpfreaks.com/topic/110932-need-help-file-check/#findComment-569104 Share on other sites More sharing options...
ober Posted June 19, 2008 Share Posted June 19, 2008 You're missing a semi-colon after the fclose... can't you test it? Quote Link to comment https://forums.phpfreaks.com/topic/110932-need-help-file-check/#findComment-569106 Share on other sites More sharing options...
ia.studio Posted June 19, 2008 Author Share Posted June 19, 2008 I can test it with flash, can't test it with other file Quote Link to comment https://forums.phpfreaks.com/topic/110932-need-help-file-check/#findComment-569108 Share on other sites More sharing options...
ia.studio Posted June 20, 2008 Author Share Posted June 20, 2008 please help I really need to have this done. here check this link you'll know what I'm talking about, I don't know how to check this with HTML http://board.flashkit.com/board/showthread.php?t=769858 Quote Link to comment https://forums.phpfreaks.com/topic/110932-need-help-file-check/#findComment-569865 Share on other sites More sharing options...
abdfahim Posted June 20, 2008 Share Posted June 20, 2008 I saw no problem except the missing semicolon after fclose() line, as ober said. The only other thing could happen is the variable $fileName is blank or something. Try to echo it to check whether there is a valid name available in that variable. You'll want to change "a+" to "w+" and make sure you use fclose($file); at the end. http://us2.php.net/fwrite Worng. 'a+' is not a problem. from php manual 'a+' = Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it. Quote Link to comment https://forums.phpfreaks.com/topic/110932-need-help-file-check/#findComment-569872 Share on other sites More sharing options...
ia.studio Posted June 20, 2008 Author Share Posted June 20, 2008 thanks So I have to use "a+" ???. this is confusing, can you give me the html you used to make this work it may give me a hint to use it with flash. Quote Link to comment https://forums.phpfreaks.com/topic/110932-need-help-file-check/#findComment-569926 Share on other sites More sharing options...
abdfahim Posted June 20, 2008 Share Posted June 20, 2008 you can use either 'w','w+','a','a+' any one. Only difference is, for 'a' and 'a+', if file already exists, they will append the new text. For the rest two, they always delete all the texts (if file exist). If file does not exist, all are same. Quote Link to comment https://forums.phpfreaks.com/topic/110932-need-help-file-check/#findComment-569930 Share on other sites More sharing options...
abdfahim Posted June 20, 2008 Share Posted June 20, 2008 Hey, you tried it with ending semicolon( placed after fclose() line? I try your code and it works man!! <?php $fileName = $_POST['fName'].".html"; $fileText = $_POST['fText']; $file=fopen($fileName,"w+"); fwrite($file,$fileText); fclose($file); echo "&resu=Created ".$fileName; ?> As I said, the other possibilities is, may be somehow you dont get the POST variable write. To ensure that, print those two post variables <?php $fileName = $_POST['fName'].".html"; $fileText = $_POST['fText']; echo "this is file name : ".$fileName; //check whether these two lines print what you wish echo "this is file text : ".$fileText; //check whether these two lines print what you wish $file=fopen($fileName,"w+"); fwrite($file,$fileText); fclose($file) echo "&resu=Created ".$fileName; ?> and remember, in this case, file will be created in the same folder where your php file is. Quote Link to comment https://forums.phpfreaks.com/topic/110932-need-help-file-check/#findComment-569945 Share on other sites More sharing options...
ia.studio Posted June 20, 2008 Author Share Posted June 20, 2008 thanks abdbuet So the problem has to be Flash CS3. lol Quote Link to comment https://forums.phpfreaks.com/topic/110932-need-help-file-check/#findComment-569953 Share on other sites More sharing options...
abdfahim Posted June 20, 2008 Share Posted June 20, 2008 ok .. then sorry .. but you do check this two line, right? echo "this is file name : ".$fileName; //check whether these two lines print what you wish echo "this is file text : ".$fileText; //check whether these two lines print what you wish [code] and get the $fileName printed? [/code] Quote Link to comment https://forums.phpfreaks.com/topic/110932-need-help-file-check/#findComment-569956 Share on other sites More sharing options...
ia.studio Posted June 20, 2008 Author Share Posted June 20, 2008 oK Quote Link to comment https://forums.phpfreaks.com/topic/110932-need-help-file-check/#findComment-569971 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.