单引号标记错误是脚本 [英] single quote mark error is script

查看:113
本文介绍了单引号标记错误是脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个推荐页面,用户可以为我写一个推荐书。

如果用户使用单引号,我会收到此错误消息。

例如:

作为公司的网络和营销材料设计师,展现出专业性和创造力。

会产生这个错误;
您的SQL语法出错;查看与您的MySQL服务器版本相对应的手册,以获得在网络和营销材料设计师附近使用的正确语法。 '')''在第1行


这里是我的php代码:

I have a testimonial page where the user can write a testimonial for me.
I get this error message if the user use a single quote mark.
example:
Demonstrated professionalism and creativity as the company''s web and marketing materials designer.

Will produce this error;
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''s web and marketing materials designer. '')'' at line 1

here is my code for the php:

展开 | 选择 | Wrap | 行号

推荐答案

首先要注意的是
first thing to notice


_POST [name] 应该是
_POST[name] should be


_POST [" name"] ,否则你会收到一些通知。


秒,你对SQL注入很开放。 (这是你的错误的原因)

它是粗心的,不处理用户输入。你至少应该使用 mysql_real_escape_string()



三,可变测试
_POST["name"], otherwise you get a couple of notices.

second, you?re wide open to SQL Injection. (which is the reason for your error)
it is careless, not to treat user input. the least you should do is using mysql_real_escape_string().


third, variable testing
展开 | 选择 | Wrap | 行号


这篇关于单引号标记错误是脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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