web_master Posted October 4, 2007 Share Posted October 4, 2007 Hi, I got 2 "str_replace"-es in script. One is for a smilies and looks like: $s = str_replace(": )","<img src=\"media/icons/smilie_01.gif\">", $s); The other is: $s = str_replace(".",". ", $s); Well, when I add the latest str_replace (dot change to dot+space) the images is dissapears... In source code the image src looks like this: <img src="media/icons/smilie_01.%20gif"> What can I do, to str_replace don't chande the dot to dot+space in img - "smilie_01.gif -> smilie_01.%20gif"? Thanx in advanced!!! Quote Link to comment https://forums.phpfreaks.com/topic/71778-str_replace-problem-with-img/ Share on other sites More sharing options...
heckenschutze Posted October 4, 2007 Share Posted October 4, 2007 Why are you replacing '.' with '. ' ? Time for you to learn regex me thinks. Quote Link to comment https://forums.phpfreaks.com/topic/71778-str_replace-problem-with-img/#findComment-361484 Share on other sites More sharing options...
willpower Posted October 4, 2007 Share Posted October 4, 2007 you will be breaking the url as whitespace in a url is not allowed. as all characters need to be present the " " (space) is substiuted by %20 Give me the RAW data presumably $s before you manipulate it and give me what you WANT the output to be. And as the last poster said....if you DO need a space, please advise WHY Will Quote Link to comment https://forums.phpfreaks.com/topic/71778-str_replace-problem-with-img/#findComment-361486 Share on other sites More sharing options...
web_master Posted October 4, 2007 Author Share Posted October 4, 2007 well... This changes is for a better look of shout-box. The shout boxes width is given. But lots of a visitors when read texts forgot to insert the space after the dot (and comma). This result somethimes the very wide "word". And this result that a shout-box need a scrollink when You want to read this text. As You see this will be a "cosmetic" only. Quote Link to comment https://forums.phpfreaks.com/topic/71778-str_replace-problem-with-img/#findComment-361496 Share on other sites More sharing options...
d.shankar Posted October 4, 2007 Share Posted October 4, 2007 Did this work ? $s = str_replace(".",".%20", $s); Quote Link to comment https://forums.phpfreaks.com/topic/71778-str_replace-problem-with-img/#findComment-361498 Share on other sites More sharing options...
web_master Posted October 4, 2007 Author Share Posted October 4, 2007 No, its NOT work Quote Link to comment https://forums.phpfreaks.com/topic/71778-str_replace-problem-with-img/#findComment-361501 Share on other sites More sharing options...
heckenschutze Posted October 4, 2007 Share Posted October 4, 2007 That's not the problem, the path to the image is going to be invalidated no matter what you do. $s = str_replace(".",".%20", $s); meaning, '.' would become, '.%2520' Quote Link to comment https://forums.phpfreaks.com/topic/71778-str_replace-problem-with-img/#findComment-361502 Share on other sites More sharing options...
web_master Posted October 4, 2007 Author Share Posted October 4, 2007 that mean to neead a double change? 1. $s = str_replace(".",". ", $s); 2. $s = str_replace("gif. ","gif.", $s); Quote Link to comment https://forums.phpfreaks.com/topic/71778-str_replace-problem-with-img/#findComment-361504 Share on other sites More sharing options...
web_master Posted October 4, 2007 Author Share Posted October 4, 2007 NOT WORK.... Quote Link to comment https://forums.phpfreaks.com/topic/71778-str_replace-problem-with-img/#findComment-361507 Share on other sites More sharing options...
heckenschutze Posted October 4, 2007 Share Posted October 4, 2007 You haven't explained WHY you need to replace a full-stop with a full-stop and a space, nor have you given what $s contains as willpower asked for. Quote Link to comment https://forums.phpfreaks.com/topic/71778-str_replace-problem-with-img/#findComment-361508 Share on other sites More sharing options...
web_master Posted October 4, 2007 Author Share Posted October 4, 2007 <?php $query_shout_return = mysql_query ("SELECT * FROM `shout_box` WHERE shout_mutat = '1' ORDER BY `shout_id` DESC LIMIT 0, 30"); if(!$query_shout_return) { print mysql_error(); exit; } while($request_shout_return = mysql_fetch_array($query_shout_return)) { $s = nl2br($request_shout_return['shout_txt']); $s = str_replace(": )","<img src=\"media/icons/smilie_01.gif\">", $s); $s = str_replace(":-)","<img src=\"media/icons/smilie_01.gif\">", $s); $s = str_replace(": (","<img src=\"media/icons/smilie_02.gif\">", $s); $s = str_replace(":-(","<img src=\"media/icons/smilie_02.gif\">", $s); $s = str_replace(": D","<img src=\"media/icons/smilie_03.gif\">", $s); $s = str_replace(",",", ", $s); ?> $s is a shout-boxes text Quote Link to comment https://forums.phpfreaks.com/topic/71778-str_replace-problem-with-img/#findComment-361510 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.