fetch\u assoc()在移动到本地服务器后不工作

hyrbngr7  于 2021-06-20  发布在  Mysql
关注(0)|答案(0)|浏览(182)

我有这样的代码,基本上找到了产品的下一个零件号,这是在我们的服务器上,它一直工作得很好。我把它移到了我的新电脑(mac)上,不知什么原因,代码停止了工作。我所有的数据库都连接正常,我的文件都放在正确的地方,但是由于某些原因,我在盒子里发现了这个错误-
致命错误:在第34行的/applications/mamp/htdocs/app/part number/part\u number.php中对boolean上的成员函数fetch\u assoc()调用
下面是引用错误的代码。。

//------new Database Connection for querying product numbers--------//
$mysqli2 = new mysqli("localhost", "testing", "testing", "testing");

//----------ABC Next Number Generator-----------/
$abc_query = "SELECT min(code) as POSSIBLE_MIN_ID
FROM
(
  SELECT concat('ABC', lpad(num,3,'0')) as code
  FROM
  (
    SELECT a.x + b.x * 2 + c.x * 4 + d.x * 8 + e.x * 16 + f.x * 32 +
           g.x * 64 + h.x * 128 + i.x * 256 + j.x * 512 as num
    from (select 0 as x union all select 1) a
    cross join (select 0 as x union all select 1) b
    cross join (select 0 as x union all select 1) c
    cross join (select 0 as x union all select 1) d
    cross join (select 0 as x union all select 1) e
    cross join (select 0 as x union all select 1) f
    cross join (select 0 as x union all select 1) g
    cross join (select 0 as x union all select 1) h
    cross join (select 0 as x union all select 1) i
    cross join (select 0 as x union all select 1) j
  ) numbers
  WHERE num between 1 and 999
) codes
WHERE code not in (select id from products);";
$abc_result = $mysqli2->query($abc_query);
while($abc = $abc_result->fetch_assoc()) { //----- THIS WOULD BE LINE 34 ITS TALKING ABOUT---//
		$abcid = $abc["POSSIBLE_MIN_ID"];
}

应用程序中的其他一切都可以正常工作,这是我遇到的唯一问题,代码与服务器上的文件完全相同,只是不同的数据库连接。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题