doudiaozhi6658 2012-05-21 18:43
浏览 45
已采纳

传递URL的多个变量

I need some help with this! I´m passing multiple variables through URL and on the landing page I have this in my code:

str = "
    SELECT
    *
    FROM wp_usermail
    WHERE ID= ".@$_GET['ID']"& Till=".@$_GET['Till'];

I want to be more accurate to select the right information from the database so both ID and Till needs to be correct otherwise you cant see the content on the page.

Right now I get parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING

  • 写回答

2条回答 默认 最新

  • dpn517111 2012-05-21 18:46
    关注

    Replace it with this:

    $str = "
    SELECT
    *
    FROM wp_usermail 
    WHERE ID = '" . mysql_real_escape_string ($_GET ['ID']) . "' AND Till = '" . mysql_real_escape_string ($_GET ['Till']) . "'";
    

    You were missing the $ in the variables' name, multiple .s, correct quotes around your variables and you didn't escape the input, which you should always do for security.

    One more thing: you should stop using the mysql_* functions and start using either mysqli or PDO, since mysql_* are now deprecated.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?