m00gzilla Posted September 21, 2006 Share Posted September 21, 2006 Hi - my first post hereI have a flat file that gets created in PHP and read in Flash. The problem I am having is when Flash shows the text from the flat file, it bring's with it escape codes (\n) and html nbsp codes.Is there something in the php script I need to add to keep it from doing this?? Originally when I was testing from the Flash .swf file, it read the text fine without any extra characters. So, i'm assuming now it's coming from the PHP side.Any help would be great!Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/21492-problem-with-flat-file-being-read-by-flash/ Share on other sites More sharing options...
trillion Posted September 21, 2006 Share Posted September 21, 2006 I don't know how you are getting your text to the php but this example will change '/n' to ' ' in the input from a $_POST form submit$texttopass = str_replace("\n"," ",$_POST['textfromphp']);put a line like this after your input is recieved and before your text file is written to Quote Link to comment https://forums.phpfreaks.com/topic/21492-problem-with-flat-file-being-read-by-flash/#findComment-95838 Share on other sites More sharing options...
m00gzilla Posted September 21, 2006 Author Share Posted September 21, 2006 Thanks Trillion. That helped clean up some of it. Now I am still getting the escape character whenever quotes are used.example: This is what it shows if I use \"quotes\". Quote Link to comment https://forums.phpfreaks.com/topic/21492-problem-with-flat-file-being-read-by-flash/#findComment-96099 Share on other sites More sharing options...
Wintergreen Posted September 21, 2006 Share Posted September 21, 2006 instead of str_replace try ereg_replace("\s+", " ", $string);That should take any tabs, newlines and white space and convert it to a single space Quote Link to comment https://forums.phpfreaks.com/topic/21492-problem-with-flat-file-being-read-by-flash/#findComment-96120 Share on other sites More sharing options...
m00gzilla Posted September 21, 2006 Author Share Posted September 21, 2006 [quote author=Wintergreen link=topic=108878.msg438771#msg438771 date=1158850818]instead of str_replace try ereg_replace("\s+", " ", $string);That should take any tabs, newlines and white space and convert it to a single space[/quote]ok, tried that. It removed all the 's' characters from the string and replaced them with blanks. Quote Link to comment https://forums.phpfreaks.com/topic/21492-problem-with-flat-file-being-read-by-flash/#findComment-96143 Share on other sites More sharing options...
m00gzilla Posted September 23, 2006 Author Share Posted September 23, 2006 ok, here is my php code[code]<?phpif (isset($_POST['Description'])) // If form was submitted with a message{ $File = 'news.txt'; // Set filename $Handle = fopen($File, 'w'); // If file does not exist, create it $rep = str_replace("\n"," ",$_POST['Description']); $Write = fwrite($Handle, $rep); // Write the new entry to the end $Close = fclose($Handle); // Close the file}?>[/code]I'm still having the issue of anytime a quote is used I get /" /" instead of " " Quote Link to comment https://forums.phpfreaks.com/topic/21492-problem-with-flat-file-being-read-by-flash/#findComment-97211 Share on other sites More sharing options...
wildteen88 Posted September 23, 2006 Share Posted September 23, 2006 Use [url=http://php.net/stripslashes]stripslashes[/url] in that case. Your serverprobably has a setting called magic_quotes enabled which escapes quotes automatically, thus you get \" instead of ". stripslashes will unescape the escaped characters. Quote Link to comment https://forums.phpfreaks.com/topic/21492-problem-with-flat-file-being-read-by-flash/#findComment-97213 Share on other sites More sharing options...
m00gzilla Posted September 23, 2006 Author Share Posted September 23, 2006 Thanks!!!Worked perfectly... Quote Link to comment https://forums.phpfreaks.com/topic/21492-problem-with-flat-file-being-read-by-flash/#findComment-97222 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.