gpt4 book ai didi

php - PDO 抛出通知 : Undefined index when using fetchAll in a WHILE loop

转载 作者:可可西里 更新时间:2023-11-01 08:09:33 26 4
gpt4 key购买 nike

我是 PHP 领域的新手,我需要一些帮助。我正在尝试从数据库中提取数据,我正在使用 PDO 来完成它。我有以下 PHP 代码但没有成功,返回错误通知:

$pairingsistem='1'; 
$pecahan='1';

if($pairingsistem == "1"){

$skrg=time();
$tablaz = $pdo->query("SELECT * FROM tb_gh where saldo > 0 and status='pending' order by id ASC limit 0,1");
while ($registroz = $tablaz ->fetchAll(PDO::FETCH_ASSOC)){
//use $results
$kurirz=$registroz["username"]; //line 47 starts here
$biayaz=$registroz["saldo"];
$idnyaz=$registroz["id"];
$bankeem=$registroz["bank"];
$norekeem=$registroz["norek"];
$bitcoineem=$registroz["bitcoin"];
$pmeem=$registroz["perfectmoney"];
$fasapayeem=$registroz["fasapay"];
$namaeem=$registroz["nama"];
$phoneeem=$registroz["phone"];
$emaileem=$registroz["email"];
$paketzeem=$biayaz*$pecahan;
$surabaya=$paketzeem/$pecahan;
//shortline

Notice: Undefined index: username in /home/u427750052/public_html/automatch.inc.php on line 47

Notice: Undefined index: saldo in /home/u427750052/public_html/automatch.inc.php on line 48

Notice: Undefined index: id in /home/u427750052/public_html/automatch.inc.php on line 49

Notice: Undefined index: bank in /home/u427750052/public_html/automatch.inc.php on line 50

Notice: Undefined index: norek in /home/u427750052/public_html/automatch.inc.php on line 51

Notice: Undefined index: bitcoin in /home/u427750052/public_html/automatch.inc.php on line 52

Notice: Undefined index: perfectmoney in /home/u427750052/public_html/automatch.inc.php on line 53

Notice: Undefined index: fasapay in /home/u427750052/public_html/automatch.inc.php on line 54

Notice: Undefined index: nama in /home/u427750052/public_html/automatch.inc.php on line 55

Notice: Undefined index: phone in /home/u427750052/public_html/automatch.inc.php on line 56

Notice: Undefined index: email in /home/u427750052/public_html/automatch.inc.php on line 57

这是警告。尽管到目前为止,我已经在我的知识范围内解决了所有可能的问题。

最佳答案

你的 whilefetchAll 让你离开这里。您需要循环 fetchfetchall 然后迭代返回的结果。

所以要么:

while ($registroz = $tablaz ->fetch(PDO::FETCH_ASSOC)){ 

$registroz = $tablaz ->fetchAll(PDO::FETCH_ASSOC);
foreach($registroz as $row) {

但由于您只返回 1 行,因此您不需要循环或 fetchall

$registroz = $tablaz ->fetch(PDO::FETCH_ASSOC);

应该可以解决问题。

关于php - PDO 抛出通知 : Undefined index when using fetchAll in a WHILE loop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45406109/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com