Michael4172 Posted June 8, 2006 Share Posted June 8, 2006 I have a script hat works fine, but whenmy WYSIWYG editor inserts in [code]nbsp;[/code]Into the echo portion of the script, it breaks it due to having the ; in the nbsp portion. Any ideas of how to overcome this since I can't make the WYSIWYG editor stop inserting that? Quote Link to comment https://forums.phpfreaks.com/topic/11495-nbsp-breaking-php-script/ Share on other sites More sharing options...
kenrbnsn Posted June 8, 2006 Share Posted June 8, 2006 Please post the code that is causing the problem. I use \ in PHP without problems.Ken Quote Link to comment https://forums.phpfreaks.com/topic/11495-nbsp-breaking-php-script/#findComment-43235 Share on other sites More sharing options...
Michael4172 Posted June 8, 2006 Author Share Posted June 8, 2006 [!--quoteo(post=381444:date=Jun 8 2006, 11:47 AM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Jun 8 2006, 11:47 AM) [snapback]381444[/snapback][/div][div class=\'quotemain\'][!--quotec--]Please post the code that is causing the problem. I use \ in PHP without problems.Ken[/quote]Well my question is how to auto insert \ whenever comes up. Here's a sample:[code]echo '<span class="par_1"><p>The single most important criterion used for selection is that the prospective company should be able to meet and maintain the standards expected by the end users.</p>';[/code]The WYSIWYG editor auto inserts that bit. Quote Link to comment https://forums.phpfreaks.com/topic/11495-nbsp-breaking-php-script/#findComment-43238 Share on other sites More sharing options...
kenrbnsn Posted June 8, 2006 Share Posted June 8, 2006 The "\" in my post was an attempt to get this forum not to interpret the '\ ' not that I use it in my scripts.Your sample should be fine. Why do you think it is breaking PHP?Ken Quote Link to comment https://forums.phpfreaks.com/topic/11495-nbsp-breaking-php-script/#findComment-43246 Share on other sites More sharing options...
Michael4172 Posted June 8, 2006 Author Share Posted June 8, 2006 [!--quoteo(post=381455:date=Jun 8 2006, 12:08 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Jun 8 2006, 12:08 PM) [snapback]381455[/snapback][/div][div class=\'quotemain\'][!--quotec--]The "\" in my post was an attempt to get this forum not to interpret the '\ ' not that I use it in my scripts.Your sample should be fine. Why do you think it is breaking PHP?Ken[/quote]Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in/home//htdocs/example.php on line That's the only ; on that line... Quote Link to comment https://forums.phpfreaks.com/topic/11495-nbsp-breaking-php-script/#findComment-43249 Share on other sites More sharing options...
nogray Posted June 8, 2006 Share Posted June 8, 2006 The line number is not accurate all the time, usually the error is around that line, so check the lines above and under.if you want ot replace the " " use the str_replace(" ", " ", 'Your text'); Quote Link to comment https://forums.phpfreaks.com/topic/11495-nbsp-breaking-php-script/#findComment-43261 Share on other sites More sharing options...
poirot Posted June 8, 2006 Share Posted June 8, 2006 [!--quoteo(post=381458:date=Jun 8 2006, 09:17 AM:name=BigMike)--][div class=\'quotetop\']QUOTE(BigMike @ Jun 8 2006, 09:17 AM) [snapback]381458[/snapback][/div][div class=\'quotemain\'][!--quotec--]Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in/home//htdocs/example.php on line That's the only ; on that line...[/quote]I guess there is an un-terminated line; like:[code]<?phpecho "something"someFuntion();?>[/code][!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in blahblahblah.php on line 4[/quote]But it could be anything. Check the lines near it for missing code. Quote Link to comment https://forums.phpfreaks.com/topic/11495-nbsp-breaking-php-script/#findComment-43275 Share on other sites More sharing options...
Michael4172 Posted June 8, 2006 Author Share Posted June 8, 2006 aha...I finally see what the problem was. Here's a sample:[code]echo 'If you haven't been here long, you may want to leave.';[/code]Thus the ' in haven't was causing the problem. I tried the string replace earlier to auto do away with these and put a \' before them all, but haven't figured that out yet. I have it as:[code]$text = str_replace("'", "\'", 'If you haven't been here long, you may want to leave.');[/code]But it still breaks when it gets to n't. Any ideas on that one? Quote Link to comment https://forums.phpfreaks.com/topic/11495-nbsp-breaking-php-script/#findComment-43313 Share on other sites More sharing options...
poirot Posted June 8, 2006 Share Posted June 8, 2006 You can use addslashes() or htmlentities with ENT_QUOTES/ENT_NOQUOTES:[a href=\"http://www.php.net/addslashes\" target=\"_blank\"]http://www.php.net/addslashes[/a][a href=\"http://www.php.net/htmlentities\" target=\"_blank\"]http://www.php.net/htmlentities[/a] Quote Link to comment https://forums.phpfreaks.com/topic/11495-nbsp-breaking-php-script/#findComment-43320 Share on other sites More sharing options...
Michael4172 Posted June 8, 2006 Author Share Posted June 8, 2006 [!--quoteo(post=381529:date=Jun 8 2006, 02:38 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 8 2006, 02:38 PM) [snapback]381529[/snapback][/div][div class=\'quotemain\'][!--quotec--]You can use addslashes() or htmlentities with ENT_QUOTES/ENT_NOQUOTES:[a href=\"http://www.php.net/addslashes\" target=\"_blank\"]http://www.php.net/addslashes[/a][a href=\"http://www.php.net/htmlentities\" target=\"_blank\"]http://www.php.net/htmlentities[/a][/quote]I don't want the / to appear. If I do either of those it actually appears. Quote Link to comment https://forums.phpfreaks.com/topic/11495-nbsp-breaking-php-script/#findComment-43366 Share on other sites More sharing options...
nogray Posted June 8, 2006 Share Posted June 8, 2006 you can replace the ' with & # 3 9 ; using str_replace (without the spaces)This will print out the ' in any browser. Quote Link to comment https://forums.phpfreaks.com/topic/11495-nbsp-breaking-php-script/#findComment-43375 Share on other sites More sharing options...
Michael4172 Posted June 8, 2006 Author Share Posted June 8, 2006 I tried this to no avail.[code]<?php$text = str_replace("'", "'", 'If you haven't been here long, you may want to leave.');echo $text;?> [/code]I regularly have things like <div id = "blah"> is the reason I rather use single quotes as oppose to the double on the end. Quote Link to comment https://forums.phpfreaks.com/topic/11495-nbsp-breaking-php-script/#findComment-43383 Share on other sites More sharing options...
poirot Posted June 8, 2006 Share Posted June 8, 2006 str_replace should do, but you can also use htmlentities or htmlspecialchars with ENT_QUOTES:[code]$string = htmlentities($string, ENT_QUOTES);[/code][a href=\"http://www.php.net/htmlentities\" target=\"_blank\"]http://www.php.net/htmlentities[/a][a href=\"http://www.php.net/htmlspecialchars\" target=\"_blank\"]http://www.php.net/htmlspecialchars[/a]They will replace " ' " with & #039;Post #625, that is 25^2 or 5^4. I like this number [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] Quote Link to comment https://forums.phpfreaks.com/topic/11495-nbsp-breaking-php-script/#findComment-43391 Share on other sites More sharing options...
Michael4172 Posted June 9, 2006 Author Share Posted June 9, 2006 [!--quoteo(post=381601:date=Jun 8 2006, 05:12 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 8 2006, 05:12 PM) [snapback]381601[/snapback][/div][div class=\'quotemain\'][!--quotec--]str_replace should do, but you can also use htmlentities or htmlspecialchars with ENT_QUOTES:[code]$string = htmlentities($string, ENT_QUOTES);[/code][a href=\"http://www.php.net/htmlentities\" target=\"_blank\"]http://www.php.net/htmlentities[/a][a href=\"http://www.php.net/htmlspecialchars\" target=\"_blank\"]http://www.php.net/htmlspecialchars[/a]They will replace " ' " with & #039;Post #625, that is 25^2 or 5^4. I like this number [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /][/quote]Ok thanks I shall give that a try and play with it some :) Quote Link to comment https://forums.phpfreaks.com/topic/11495-nbsp-breaking-php-script/#findComment-43825 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.