Home > Backend Development > PHP Tutorial > 请问sql注入有关问题

请问sql注入有关问题

WBOY
Release: 2016-06-13 11:56:17
Original
895 people have browsed it

请教sql注入问题
大家好 前几天做了个网站  考虑到我没有做sql防注入  这几天看了一些案列 用在我自己的网站上 却没反应   现在请教下 我这样写 如何构建sql代码才能被注入呢?
主要语句就是这个
include "../admin/connss.php";
$id=$_GET[id];
$sql=mysql_query("select * from news where id='$id'");
$row = mysql_fetch_array($sql);
?>

其他的都是显示的 没什么用 我感觉我没做过滤 正常这种应该被注入啊  但是我试了一些方法 没什么用 请教下
谢谢
------解决方案--------------------
addslashes或者mysql_real_escape_string都可以转义字段 防止注入
------解决方案--------------------

<br />-- 你的程序设计是这个样子的: <br />-- $id=“100”<br />select ....from... where ID = '100' ; <br />-- SQL注入的结果是下面的样子:<br />-- $id = "100' or '1' ='1"<br />select .... from .... where ID ='100' or '1' ='1' <br /><br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template