我有执行此操作的代码,基本上可以找到位于我们服务器上的产品的下一个部件号,并且效果很好。我已将其移至新计算机(mac),并且由于某种原因该代码停止工作。我的所有数据库均已正确连接,并且文件位于正确的位置,但是由于某些原因,我在框中出现了此错误-
致命错误:在第34行的/Applications/MAMP/htdocs/app/part-number/part_number.php中,对布尔值成员函数fetch_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"];
}
应用程序中的所有其他东西都可以正常工作,这是我唯一遇到的问题,并且代码与服务器上工作的文件完全相同,只是数据库连接不同。