English 中文(简体)
A. 避免注射q蒸功能的全球化方式
原标题:A way of globalising the mysql function to avoid sql injection

请记住,我仍在学习。 我正在一个网站上工作,我只是从现有的网站上调整和复制守则,因为这为我了解这些守则提供了最容易的途径。

我不断发现因使用异热带而产生的q错误,我已着手在每个文本领域(解决了个别问题)的<密码>-mysql_real_einski_string()。

现在,这真的只是我要求帮助。 请不要听起来,我真的只是想学习,这是提问的最佳场所,因此:

Is there any way of fixing a general setup that will filter out the apostrophes that interfere? Basically anything that will help the site in general be protected against sql injection? Any help would be greatly appreciated :)

问题回答

一般性解决办法:所有参数(价值)应通过编制报表的持有人予以通过

rel=“nofollow” http://nz.php.net/manual/en/pdo.prepare.php

是否有办法确定一个能够过滤干扰的外向的普通建筑?

Definitely NO.

很久以前就存在这样的情况,但现在,它却挥之不去,被歪曲和夸大(因为它从未像用意那样做,也没有达到目的)。

The problem you face is coming from the fact that SQL query being a program. So, you have to follow the syntax rules creating this program, just like with any other program language. If you happen to create a PHP program, you have to take care of the irritating apostrophes as well - you can t put it all over the code in random places, but each have to have it s strict syntactical meaning, or - if an apostrophe being part of the data - it have to be properly escaped.

So, it is just syntax issue.
The best way to solve the problem is to separate the code from the data.
Native prepared statements gives you that possibility.
You can create a program - the query itself - and eventually bind some variables to it, so, the program code and the date being sent to the SQL server separately.
That s why prepared statements considered the best way of creating dynamical SQL queries.

但是,当然,你们必须把每个变量都明确地加以约束——因此,没有普遍的方法。

然而,你可以利用一些助手自动地履行具有约束力的义务,因此,该守则变得简明扼要。

$db->run("SELECT * FROM table WHERE id=?",$id); 

这样做既短于书面,又完全安全。

使用数据存取层对你来说是比人工保护每个电离参数更好的办法。 这不仅是因为它ious笑了,而且因为一个关键的参数最终会消失。

我使用的是SafeSQL, 当我仍然做过PHP时,它会发现很轻又不侵扰......但如果你重新开门的话,就会把它 p为一件令人生畏的任务。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签