我有最后一个工作( simple outbound link tracker - Why isn't this working? ),问题是空格和列名大写。
现在,我试图在一个现有的数据库中实现这一点,而没有任何成功。
下面是代码(不包括mysql连接数据和混淆表名)
<?php
$id = $_GET['ID'];
/** Increase the counter of the URL to which the user is going*/
mysql_query("UPDATE `table_name` SET countout = countout + 1 WHERE ID = '$id'") or die(mysql_error());
/** Retrieves URL */
$result = mysql_query("SELECT * FROM `table_name` WHERE ID = '$id'") or die(mysql_error());
$row = mysql_fetch_array($result);
//redirects them to the link they clicked
header( "Location:" .$info['Url'] );
?>同样重要的是,下面是包含数据的db表结构的屏幕截图:
http://cl.ly/323A1i3L0n181P3H0J2B/Image%202012-01-05%20at%201.39.41%20PM.png
当我试图
out.php?id=36我得到一页空白
编辑:@Runar rgensen提供了修复程序。只是想从现在的SQL注入中保护它--
发布于 2012-01-05 21:58:04
您的脚本中有一些应该纠正的错误。您应该在开发过程中启用错误,这样您就可以看到脚本不工作的地方了。
首先:变量是区分大小写的,如果您的链接是out.php?id=36,那么您应该使用$_GET['id']而不是$_GET['ID']。
第二:您正在重定向到未设置的url,如您所见。您应该编辑标题标记,如下所示:header("Location: " . $row['Url']);
您还应该了解SQL注入,并了解如何处理它们。
https://stackoverflow.com/questions/8750276
复制相似问题