【问题标题】:how can I call a query from a variable from an included file如何从包含文件中的变量调用查询
【发布时间】:2018-09-17 23:06:36
【问题描述】:

这是我的 query.php

中的代码
     $ubh = "SELECT
     ec_product.kode
     FROM
     ec_product
     WHERE
     ec_product.dtcode = '1' AND
     ec_product.kode_agencyplatform = '$kodeParnter' AND
     ec_product.kode = '$kode'";

     $qbaru = "SELECT
     GROUP_CONCAT(kode_category) 
     FROM 
     ec_product_category 
     WHERE 
     kode_product = '' 
     AND 
     dtcode ='1'";

这是我的另一个ubah.php

      include "query.php";
      $r = mysqli_fetch_array(mysqli_query($conn, "$ubh"));

如何为 ubah.php 调用$qbaru 而不是调用$ubh

对不起我的英语不好

【问题讨论】:

  • 使用$qbaru 变量?什么不适合你?你不检查错误吗?
  • 不要在 SQL 查询中插入字符串。请改用parameterized queries
  • 您的问题不清楚,因此投票结束,因为您没有告诉我们什么不适合您。也离开这个职位。

标签: php mysql variables include


【解决方案1】:

两个变量都在同一个文件中,所以如果你可以调用 $ubh 那么调用 $qbaru 应该没有问题。如果有错误,请提供错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-08
    • 2021-11-04
    • 2011-03-21
    • 1970-01-01
    相关资源
    最近更新 更多