CKEditor images not working

不问归期 提交于 2019-12-25 07:51:59

问题


I'm having some trouble with CKEditor.

I have created a blog for my website and a back end section to write new posts and approve comments etc. It's all working fine and I use CKEditor to write and edit posts.

When writing a text only post its fine, it gets stored in the database and subsequently appears on the website as it should. But If I write a post with an image in it it doesnt get stored in the database. All text and images disappear.

The title of the post goes into the database as this is just using a normal text box. But everything in the CKEditor disappears if I put an image in there.

Here are some screen shots:

I press the image button and enter in the explicit URL of the image stored on my server. (http://www.mydomain.com/images/image.jpg)

When I press ok the image is visible in CKEditor with the text above it.

When I submit the post and then return to it to view or edit it, the CKEditor is empty and only the Title is there. Checking the database I can see the title is entered but the body isnt.

If I dont enter an image everything works fine title and body go into the database and the blog post appears on the site.

Does anyone have any idea whats wrong here?


回答1:


I actually discovered the answer myself

The image tags created in the CKEditor would be something like

<img src="images/picture.jpg">

and my SQL query would be something like

$query = "INSERT INTO Table (blog_body, blog_title) VALUES ('".$blogBody."','".$blogTitle."')";

or something along those lines.

To solve it I just swapped the quotation marks around. Placing the query in single quotes and swapping the quotes about the variables around.

This fixed my problem.

Just thought if someone else is having this trouble this may help



来源:https://stackoverflow.com/questions/21023546/ckeditor-images-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!