Yesterday, Hao Duanduan’s website suddenly failed to display the uploaded images and couldn’t center them. The backend used ckeditor. Then I got into deep thought. At first I thought it was a problem with the editor. I tried changing the editor, but the problem was still the same. Obviously, the problem with the editor was ruled out. So what's the problem?
From the source code analysis of the input content of the editor, the content contains quotation marks and HTML tags, but when submitting, ckeditor will convert predefined characters such as "<" into HTML entities, and the content after storage will be converted Later it was materialized.
Through querying the database results, we learned that the quotation marks in the content were replaced and became blank. However, the output data can still be interpreted in the editor, but the style is a mess, and some other tags have been added. It is these that cause the front-end style to be messed up and the uploaded image to be unable to be displayed and centered.
Now that we have found out the reason, the next step is to come up with solutions.
At this time I thought of the magic_quotes_gpc parameter in the php configuration file. As expected, this parameter is in the Off state. When enabled, data passed through GET, POST, and COOKIE will be automatically escaped.
If magic_quotes_gpc=Off; then the characters must contain quotation marks (regardless of single quotation marks or double quotation marks), and writing directly to mysql will directly become blank.
Obviously this problem is caused, so we turn on this parameter magic_quotes_gpc=On. The data inserted into the database is displayed normally, and the quotation marks are replaced with (backslashes).
When fetching data, use $contents = preg_replace("/\\/",'"',$contents); to replace it, and it will be displayed normally in the editor.
This problem is solved. About warehousing The use of data escape parameters will be summarized later in the article.
Original text: http://www.francissoung.com/biancheng/178.html
The above introduces the solution to the problem that the images uploaded by the Ckeditor editor cannot be centered and the styles are disordered, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.