Welcome to WebmasterWorld Guest from 54.159.26.69

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Error fetching array (mysql)

Error fetching array (mysql)

     

Sweetie

11:52 am on Feb 5, 2013 (gmt 0)



Hello!
Here the code:

$db->query("SELECT * FROM bill_temp WHERE user_id='".$usrid."'");
// Check if have rows
if($db->numrows() != 0)
{
while($row = $db->getRows())
{
$txn_id = $row['num_bill'];
}
foreach($q->billStatus($txn_id,TRUE) as $idbill=>$v)
{
$mp = $v['amount'];
if($v['status'] == 60)
{
$db->query("SELECT amount FROM bill_temp WHERE user_id='".$usrid."' AND num_bill='".$idbill."'");
while($row = $db->getRows()) $moneyCheck = $row['amount'];
// Amount checking
if($moneyCheck == $mp)
{
//some code
}
else {
//some code
}
}
if($v['status'] > 100)
{
//some code
}
}
}
else
echo ('numrows == 0');

But code fails at: $txn_id = $row['num_bill'];
Undefined index: num_bill (in this line: $txn_id = $row['num_bill'];)
Here the var_dump($row):
array(1) { [0]=> array(3) { ["user_id"]=> string(1) "1" ["num_bill"]=> string(8) "s7M1RxCf" ["amount"]=> string(2) "11" } }

What's wrong in code?

jadebox

7:38 pm on Feb 5, 2013 (gmt 0)

10+ Year Member



I have to assume that $db->getRows() returns a list of the rows returned from the query. If that's the case, it's not surprising that "$row['num_bill']" is not defined.

You probably need to enumerate row returned by getRows(). I don't know what class you've used, but you probly need to do something like:

$rows = $db->getRows();
foreach ($rows as $row)
{
$txn_id = $row['num_bill'];
...
}
 

Featured Threads

Hot Threads This Week

Hot Threads This Month