【问题标题】:Php help find where is syntax error [closed]php帮助查找语法错误在哪里[关闭]
【发布时间】:2015-03-06 15:12:07
【问题描述】:
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

【问题讨论】:

  • 不要使用 3 ===。一个就够了

标签: php mysql


【解决方案1】:

这个

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

如果您将查询结果存储在变量中并循环访问该变量,则最佳实践。

【讨论】:

  • @user3801263 一个不错的隐秘编辑?不,您可能认为这个答案没有用,因为您只是编辑了您的问题,甚至没有将其标记为编辑
  • @Rizier123 我该怎么办???新手在这里
  • @user3801263 让代码像原来一样,在底部写:EDIT: i have tried this/or done this but it still doesn't work 也显示你自己尝试过的内容
【解决方案2】:
 foreach($db->fetch_array("SELECT id_categories FROM csn_categories_join_kartes where id_kartes=".$card['id']."") as $kat)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-13
    • 1970-01-01
    • 2018-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-24
    相关资源
    最近更新 更多