Jump to content

Archived

This topic is now archived and is closed to further replies.

lordphate

Confused on this...

Recommended Posts

Warning: Invalid argument supplied for foreach() in /home/*/public_html/order/EP_Dev_cPanel_API_PHP4.php on line 497
  Okay...so here's the code 10 lines before and after...
[code]
$this->accountList = $accountList;
}


/**
* Parse fetched account list for domain list, user package list,
* and reseller list.
*/
function parseAccountList()
{
foreach($this->accountList as $reseller => $reseller_data)    LINE ERROR!
{
foreach($reseller_data as $user => $user_data)
{
$this->domainList[$user] = $user_data['domain'];
$this->userPackageList[$user] = $user_data['package'];
$this->resellerList[$reseller][$user] = $user_data['domain'];
}
}
}
[/code]

Share this post


Link to post
Share on other sites
We need to see the accountList method.

Share this post


Link to post
Share on other sites
Cool. That helps heaps!

Once again, we need to see the accountList method.

PS: If this isn't your script your in the wrong forum, we have one especially for help with 3rd party scripts.

Share this post


Link to post
Share on other sites
Actually... its not a method. At the very top of your code snippet you have the line....

[code]
$this->accountList = $accountList;
[/code]

Where is $accountList being created?

Share this post


Link to post
Share on other sites
It is my script here's the accountList:
[code] function fetchAccountList()
{
$result = $this->doCommand("/scripts/reslist");

$match = preg_match("/<html>.*?<tr class=\"tblheader\">.*?(<tr class=\"tblheader\">.*?)<\/table><\/html>/is", $result, $matches);

if ($match)
{
$second_matches = explode("<tr class=\"tblheader\">", $matches[1]);

foreach($second_matches as $key => $value)
{
unset($all_matches);

// skip key 0 (empty)
if ($key == 0)
continue;

if (preg_match_all("/.*?<b><u>(.*?)<\/u><\/b>.*?<b>.*?<\/b>.*?<b>(.*?)<\/b>(.*<\/tr>)/is", $value, $all_matches, PREG_SET_ORDER))
{
for($i=0; $i<count($all_matches); $i++)
{
$reseller_username = $all_matches[$i][1];
$reseller_domain = $all_matches[$i][2];
$reseller_data = $all_matches[$i][3];

// set this intially... although it will likely be set again (but that doesn't matter)
$accountList[$reseller_username][$reseller_username]['domain'] = $reseller_domain;
$accountList[$reseller_username][$reseller_username]['package'] = "undefined";

if (preg_match_all("/<tr class=\"tdshade[12]+\"><td>(.*?)<\/td>.*?<td>(.*?)<\/td>.*?<td>(.*?)<\/td>.*?<\/tr>/is", $reseller_data, $reseller_matches, PREG_SET_ORDER))
{
for($j=0; $j<count($reseller_matches); $j++)
{
$current_user = $reseller_matches[$j][1];
$current_domain = $reseller_matches[$j][2];
$current_package = $reseller_matches[$j][3];

$accountList[$reseller_username][$current_user]['domain'] = $current_domain;
$accountList[$reseller_username][$current_user]['package'] = $current_package;
}
}
}
}
}
}

$this->accountList = $accountList;
}


/**
* Parse fetched account list for domain list, user package list,
* and reseller list.
*/
function parseAccountList()
{
foreach($this->accountList as $reseller => $reseller_data)
{
foreach($reseller_data as $user => $user_data)
{
$this->domainList[$user] = $user_data['domain'];
$this->userPackageList[$user] = $user_data['package'];
$this->resellerList[$reseller][$user] = $user_data['domain'];
}
}
} [/code]

Share this post


Link to post
Share on other sites
Whatever... its pretty hard to say whats going on, but basically the error is saying that $this->accountList is not an array. What does....

[code=php:0]
print_r($this->accountList);
[/code]

produce?

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.