Solved

\\ is creating problem

Posted on 2009-04-03
3
241 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
Comment Utility
sorry i am such stupid i was using backslashed instead of forward slashed
0
 
LVL 6

Expert Comment

by:twocandles
Comment Utility
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
Comment Utility
ooops, my mistake. :(. you're right.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.

743 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

16 Experts available now in Live!

Get 1:1 Help Now