dongtuo0828 2015-10-30 07:58
浏览 74
已采纳

PHP MySQL WHERE子句列名错误

MySQL Query:

$sSix = "SELECT count(*) as count FROM `timers` WHERE `real_id` = {$row['real_id']}";
$rSix = mysql_query($sSix, $conn2);
echo mysql_error(); die;

Result: Unknown column '985_1445542200' in 'where clause'

Column name is real_id but in result its showing column '985_1445542200'.

Could you please let me know the probable cause of error.

  • 写回答

2条回答 默认 最新

  • douxu3732 2015-10-30 07:59
    关注

    You will need quotes in your WHERE part. Like so:

    $sSix = "SELECT count(*) as count FROM `timers` WHERE `real_id` = '{$row['real_id']}'";
    

    Additionally, please consider using the newer mysqli_ functions or PDO, as the old mysql_ functions will stop working in the future.

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

报告相同问题?

悬赏问题

  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失
  • ¥15 springboot+vue 集成keycloak sso到阿里云
  • ¥15 win7系统进入桌面过一秒后突然黑屏
  • ¥30 backtrader对于期货交易的现金和资产计算的问题
  • ¥15 求C# .net4.8小报表工具
  • ¥15 安装虚拟机时出现问题
  • ¥15 Selenium+docker Chrome不能运行
  • ¥15 mac电脑,安装charles后无法正常抓包
  • ¥18 visio打开文件一直显示文件未找到