Solved

\\ is creating problem

Posted on 2009-04-03
3
243 Views
Last Modified: 2012-05-06
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

0
Comment
Question by:amitbravo
  • 2
3 Comments
 

Accepted Solution

by:
amitbravo earned 0 total points
ID: 24058422
sorry i am such stupid i was using backslashed instead of forward slashed
0
 
LVL 6

Expert Comment

by:twocandles
ID: 24058459
Double your backslash (ie, 4 backslashed):

\\\\

The backslash is a escape character. You have to double it to write one.
0
 
LVL 6

Expert Comment

by:twocandles
ID: 24058462
ooops, my mistake. :(. you're right.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question