homepage Welcome to WebmasterWorld Guest from 54.226.147.84
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Error fetching array (mysql)
Error fetching array (mysql)
Sweetie



 
Msg#: 4542494 posted 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

10+ Year Member



 
Msg#: 4542494 posted 7:38 pm on Feb 5, 2013 (gmt 0)

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'];
...
}

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved