Link to home
Start Free TrialLog in
Avatar of amitbravo
amitbravo

asked on

\\ is creating problem

I using a WYSIWYG editor which post image path like 'com_images/pic.jpg' and I need to convert it like http://www.exploroo.com/com_images/pic.jpg before submit to database or display properly on a webpage

I tried like > 

<?php
echo str_replace('src="com_images','http:\\www.exploroo.com/com_images',$_POST['text']);
?>

but it display like > <img src="http:\www.exploroo.com/com_images/pic,jpg" alt="" width="231" height="154" />

it avoids one backslash .. how could i avoid the problem

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
	tinyMCE.init({
		// General options
		mode : "textareas",
		theme : "advanced",
		plugins : "safari,pagebreak,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager",
 
		// Theme options
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontsizeselect",
		theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
		theme_advanced_buttons3 : "hr,nonbreaking,removeformat,|,sub,sup,|,charmap,emotions,iespell,media,|,print,|,ltr,rtl,|,fullscreen",
		
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : false,
 
		// Example content CSS (should be your site CSS)
		content_css : "css/content.css",
 
		// Drop lists for link/image/media/template dialogs
		template_external_list_url : "lists/template_list.js",
		external_link_list_url : "lists/link_list.js",
		external_image_list_url : "lists/image_list.js",
		media_external_list_url : "lists/media_list.js",
 
		// Replace values for the template plugin
		template_replace_values : {
			username : "Some User",
			staffid : "991234"
		}
	});
</script>
</head>
<body>
<?php
echo str_replace('src="com_images','http:\\www.exploroo.com/com_images',$_POST['text']);
?>
 
<form id="form1" name="form1" method="post" action="">
  <textarea name="text" id="text"></textarea>
  <input type="submit" name="button" id="button" value="Submit" />
</form>
 
</body>
</html>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of amitbravo
amitbravo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of twocandles
twocandles

Double your backslash (ie, 4 backslashed):

\\\\

The backslash is a escape character. You have to double it to write one.
ooops, my mistake. :(. you're right.