dongsiju1941 2012-05-26 06:07
浏览 26
已采纳

停止SQL注入[重复]

Possible Duplicate:
Best way to stop SQL Injection in PHP

I've tried googling for help, but it is not as easy as you would have imagined. If someone could just tell me how to secure the SQL, or even give me a link to a good website to learn how to do it myself.

If you could even be kind enough to fix it, and tell me what was wrong, I will definitely take note, and secure the rest of my code.

    <?php
    $post = htmlspecialchars($_GET["id"]);
    $results = mysql_query("SELECT * FROM tool WHERE id = $post");
    $authorr = $_SESSION['Username'];

while($row = mysql_fetch_array($results)){
 $capsd = ucfirst($author);
 $title= $row['title'];
 $details= $row['details'];
 $author= $row['author'];
 $date= $row['date'];
 $img= $row['featuredimage'];
 $id= $row['id'];



    echo "<table border=1><tr><td width=100px>
                 <b><u><center>";
    echo $title;
    echo "</center></u></td> <td width=100px><center>";
    echo $date;
    echo "</center></td> <td width=100px><b><center>";
    echo ucfirst($author);
    echo "</center></b></td>";

    if (in_array($authorr, $allowedposters)) {
    echo "<center><td width=20px><a href=edit.php?id=";
    echo $id;
    echo "><b>Edit</b></a></center></td>";
    }
   echo "</tr></table>";
   echo "<img src=http://www.removed.com/news/";
   echo $img;
   echo " height=300 width=400> <br><br>";
   echo $details;

   }
   ?>
  • 写回答

1条回答 默认 最新

  • douquanqiao6788 2012-05-26 06:11
    关注

    Take a look at this: How can I prevent SQL injection in PHP?

    Essentially, the answer is to use prepared statements and sanitize your input.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 C# TCP服务端,客户端退出后,不断有数据进来
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?