With CKEditor published articles, picture path more "/", How to Ah, Master advice!
This is a very strange phenomenon: I use CKEditor to publish the news, the inside add a picture, in the site I need to extract the image path, and on the homepage display. I use the method is to intercept during the submission process, using regular expressions to extract the image path. My regular expression is as follows:
"/
I am in the local environment: Win7 under apache+mysql+php; (Wamp integrated environment).
Upload the environment: Win2003 under the iis+mysql+php;
The problem is: in the local extraction of the image path without any problems, but upload the site after the extraction is not!! In order to find out the reasons, I carefully reviewed the various problems:
1, publish the article, in the CKEditor edit box in the source mode view, the result is:
“
Please add the article content here!
400px; height:300px "/>
”
When submitting an article, output the submission in the Web page (echo $_post[' content '), view the source, and the output is:
Please add the article content here!
\ "width:400px; Height:300px;\ "/>
The comparison found more than before the ' before submission '.
2, in the browser to view the article just added, the picture can be displayed correctly, view the database storage, the result is:
“
Please add the article content here!
400px; height:300px "/>
”
The result is the same as the original CKEditor in the edit box.
The above two point analysis let me not understand, from the beginning content is correct, to submit more "/", to write to the database and return to normal, what is the situation ah????
Also stressed that the site in my local when the above two analysis output of the content has not changed, all is correct!!
Hope Master Advice! Little brother to the forum, not much, in the future to earn points will be given!
------Solution--------------------
This is because of the mechanism of using string escaping
For example: "\" ", the double quote character (") can be used in the range of "" double quotes
The general use of escape, is afraid that you are using this content, there are and other double quotation marks for processing, generally more in the database SQL splicing, for example
PHP code
$a = ' I have a double quote ' '; $sql = ' SELECT * from Test WHERE title L Ink "%". $a. '% '; Just a demo, mostly with '