Solved

\\ is creating problem

Posted on 2009-04-03
3
242 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

863 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now