将包含特殊字符的值插入 MySQL 数据库 [英] Insert values containing special characters into MySQL database

查看:74
本文介绍了将包含特殊字符的值插入 MySQL 数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试使用 TinyMCE 设置评论系统,它可以处理普通字符和 PHP 标签等.但是当我用这个 ed o'neill 评论时,它只是在我的数据库中插入一个空行.

I'm currently trying to setup a comment system with TinyMCE, it's all working with normal characters and PHP tags and so on. But when I comment with this ed o'neill, it just inserts an empty row in my db.

我的表单输入中有 htmlspecialcharsmysqli_real_escape_string.

I have htmlspecialchars and mysqli_real_escape_string on the input from my form.

如何修复空行插入?

$post_content = $_POST['post_content'];
                        //$post_content = htmlspecialchars($post_content);
                        //$post_content = mysqli_real_escape_string($post_content);

推荐答案

您已经评论了您的一些代码,但 mysqli_real_escape_string 需要 2 个参数,请参阅这里

You have commented some of your code but mysqli_real_escape_string requires 2 parameters see for more information here

string mysqli_real_escape_string ( mysqli $link , string $escapestr );

你的代码应该是:

$post_content = mysqli_real_escape_string($connection,$post_content); //$connection should be your database connection string

这篇关于将包含特殊字符的值插入 MySQL 数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆