du59131 2013-05-09 10:28
浏览 8

PHP报价问题[重复]

I have a text field called user and a submit button which displays a Json string with details of a user in the database with that id. I have the following code:

$UserID = mysql_real_escape_string($_POST['User']);

$UserCoords_Query  = "Select Accuracy, Longitude, Latitude, Timestamp 
                      FROM UserDetails
                      WHERE UserId =".$UserID;

$UserCoords_result = mysql_query($UserCoords_Query);

if (mysql_num_rows($UserCoords_result) == 0) {
    echo "There are no users with an id of ". $UserID;
}

But I am getting an error of:

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /home/roseanne/public_html/display_Coords.php on line 29.

I had recently switched the type of userID in my database from int to text. It worked as an int but not since the change. Can anyone see the quotes problem?

</div>
  • 写回答

3条回答 默认 最新

  • douqi1928 2013-05-09 10:31
    关注

    Timestamp is reserved word in mysql, use ` around it

    $UserCoords_Query  = "Select `Accuracy`, `Longitude`, `Latitude`, `Timestamp`
                      FROM UserDetails
                      WHERE UserId = '".$UserID."'";
    
    评论

报告相同问题?

悬赏问题

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