PHP 帮助查找语法错误的位置


Php help find where is syntax error

foreach($db->fetch_array("SELECT id_categories FROM csn_categories_join_kartes where id_kartes===".$card['id']."") as $kat){
        echo (kat['id_categories']);
      }

表列和值都匹配,这部分代码有问题

我尝试在 kat 之前添加 $,只使用一个"=",门槛不起作用

新链接

http://pastebin.com/RPK7vEaJ

这个

where id_kartes===".$card['id']."

where id_kartes=".$card['id']."

和缺失的$

echo $kat['id_categories'];

所以完整的代码:-

foreach($db->fetch_array("SELECT id_categories FROM csn_categories_join_kartes where id_kartes='".$card['id']."'") as $kat){
        echo $kat['id_categories'];
      }

将查询结果存储在变量中并循环访问此变量的最佳做法。

 foreach($db->fetch_array("SELECT id_categories FROM csn_categories_join_kartes where id_kartes=".$card['id']."") as $kat)