dongliyi967823 2013-03-30 04:35
浏览 40

SQL命令的类型转换警告

I have been stuck on this for a while now, very beginner I know, but couldn't find any similar issues.

I am trying to display my last topic details but I'm getting a warning.

*Warning: pg_exec() [<a href='function.pg-exec'>function.pg-exec</a>]:
Query failed: 
ERROR: operator does not exist: character varying = integer LINE 4: WHERE
t_cat = 3 ^
HINT: No operator matches the given name and argument type(s). You
might need to add explicit type casts.*

Any help appreciated

$topicsearh = pg_exec($db, 
     "SELECT t_id, t_subject, t_date, t_cat
      WHERE t_cat = " . $row['s_id'] . "
      ORDER BY t_date DESC LIMIT 1"
);      
if(!$topicsearh){
          echo 'Last topic could not be displayed.';
}
else{
      while($trow = pg_fetch_assoc($topicsearh))
      echo '<a href="topicview.php?id=' . $trow['t_id'] . '">' . $trow['t_subject'] .   
          '</a> at ' . date('d-m-Y', strtotime($trow['t_date']));
}
  • 写回答

2条回答 默认 最新

  • duanbixia7738 2013-03-30 04:36
    关注

    You need to define FROM table.

    Example

    SELECT t_id, t_subject, t_date, t_cat FROM TABLE_NAME WHERE...
                                ----------^^^^^^^^^^^^^^^-----
    

    and also con-cat as below.

    WHERE t_cat = '". $row['s_id'] ."'
    
    评论

报告相同问题?

悬赏问题

  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源