dongtan1009 2014-04-08 19:35
浏览 9

查询未正确运行

I have a sqlquery which I have been playing around with in my php page BUT it isn't pulling out accurate results! I have starred at this so long now I can't see anything wrong! I am sure there is just a " or ' or ` in the wrong place!

<? 
$result = mysql_query("SELECT ReReferral_ID FROM ReReferral Where (`ReReferral_Date` >= '" . $_POST["report_date_from"] ."-04-01 00:00:00' AND `ReReferral_Date` <= '" . $_POST["report_date_from"] ."-06-30 00:00:00') AND ReReferral_ReReferral ='1'");
$num_rows = mysql_num_rows($result);
echo $num_rows;
?>

Thanks for the help!

  • 写回答

2条回答 默认 最新

  • duanqianpu6499 2014-04-08 19:42
    关注

    try this:

     $rdate = mysql_real_escape_string($_POST["report_date_from"]);
     $result = mysql_query("SELECT ReReferral_ID FROM ReReferral 
              WHERE `ReReferral_Date` BETWEEN  CONCAT('$rdate','-04-01 00:00:00') 
              AND CONCAT('$rdate','-06-30 00:00:00') 
              AND ReReferral_ReReferral ='1' ");
    
    评论

报告相同问题?

悬赏问题

  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法