如何将特殊字符插入数据库? [英] How to insert special characters into a database?

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

问题描述

任何人都可以告诉我如何在MySQL数据库中插入特殊字符?我做了一个PHP脚本,这意味着插入一些单词到数据库,虽然如果该单词包含一个',那么它不会被插入。

Can anyone tell me how to insert special characters into a MySQL database? I've made a PHP script which is meant to insert some words into a database, although if the word contains a ' then it wont be inserted.

我可以在使用PHPmyAdmin时插入特殊字符,但是在通过PHP插入它们时它不起作用。难道是PHP正在将特殊字符改变成别的东西吗?如果是这样,有没有办法使它们正确插入?

I can insert the special characters fine when using PHPmyAdmin, but it just doesn't work when inserting them via PHP. Could it be that PHP is changing the special characters into something else? If so, is there a way to make them insert properly?

推荐答案

$insert_data = mysql_real_escape_string($input_data);

假设您将数据存储为 $ input_data

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

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