gpt4 book ai didi

php - SQL 命令的类型强制转换警告

转载 作者:可可西里 更新时间:2023-11-01 00:47:06 25 4
gpt4 key购买 nike

我已经坚持了一段时间了,我知道这是一个非常初学者,但找不到任何类似的问题。

我正在尝试显示我最后一个主题的详细信息,但我收到了警告。

*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.*

感谢任何帮助

$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']));
}

最佳答案

您需要定义FROM 表。

示例

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

还有如下所示的 con-cat。

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

关于php - SQL 命令的类型强制转换警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15715011/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com