Forum Moderators: coopster

Message Too Old, No Replies

phpDomain help

Need some help or direction with buggy script.

         

erikcw

7:51 am on Mar 23, 2004 (gmt 0)

10+ Year Member



Hi All,

I purchased a script called phpDomain [www.phpdomain.net]. Well the script is pretty buggy, and the company hasn't replied to emails. So I am hoping that my fellow webmasters will be able to lend some insite.

phpDomain is a php client for the Tucows OpenSRS domain registration system.

The part that isn't working (just happens to be the most important function of the app) is the part that allows users to renew/register domains.

Whenever I try to register a domain, I get the following errors:

Warning: Cannot use a scalar value as an array in /home/httpd/vhosts/domain.net/httpdocs/domain/docs/renew.php on line 171

Warning: Invalid argument supplied for foreach() in /home/httpd/vhosts/domain.net/httpdocs/domain/docs/renew.php on line 171

Does anybody have any ideas? I'm somewhat of a php newbie, so I believe this troubleshoot may be beyond my current abilities.

Any assistance is greatly appreciated!

Thanks,
Erik

Timotheos

4:14 pm on Mar 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi erikcw,

Basically we'd need to see what is on line 171 and a little bit around it for context.

The error is because a foreach is specifically for arrays where the script is giving it a scalar value or just a simple variable. Seems like the script needs to use the is_array() function.

Tim

erikcw

6:12 pm on Mar 23, 2004 (gmt 0)

10+ Year Member



Here are lines 168-254( the if structure the code is in)

if ($opensrs->get_extension($domain)!= '.ca')
{

////////////// This is line 171 the problem function
foreach ($results['attributes'] as $ikey=>$ival){

if ($ikey == 'contact_set'){
foreach ($ival as $k=>$v){

if (is_array($v)){

if ($k == 'owner'){
$initial='oc_';
}
else
{
if ($k == 'tech'){
$initial='tc_';
}
if ($k == 'billing'){
$initial='bc_';
}
else
{
continue;
}
}

foreach ($v as $key=>$val){

if ($key == 'postal_code'){$key='postcode';}
else if ($key == 'first_name'){$key='fname';}
else if ($key == 'last_name'){$key='lname';}
else if ($key == 'org_name'){$key='oname';}

$varname="$initial$key";

$$varname=$val;

//end value assignement routine
}

//end contact type loop
}

//end contact_set loop
}

//end if is contact set
}

//end of main foreach
}
}

else
{
//arrange contact info for .ca domains
$oc_fname=$bc_fname;
$oc_lname=$bc_lname;
$oc_oname=$bc_oname;
$oc_email=$bc_email;
$oc_address1=$bc_address1;
$oc_address2=$bc_address2;
$oc_address3=$bc_address3;
$oc_city=$bc_city;
$oc_state=$bc_state;
$oc_country=$bc_country;
$oc_postcode=$bc_postcode;
$oc_phone=$bc_phone;
$oc_fax=$bc_fax;

$tc_fname=$bc_fname;
$tc_lname=$bc_lname;
$tc_oname=$bc_oname;
$tc_email=$bc_email;
$tc_address1=$bc_address1;
$tc_address2=$bc_address2;
$tc_address3=$bc_address3;
$tc_city=$bc_city;
$tc_state=$bc_state;
$tc_country=$bc_country;
$tc_postcode=$bc_postcode;
$tc_phone=$bc_phone;
$tc_fax=$bc_fax;
}

I hope this helps.

Thanks!

coopster

8:22 pm on Mar 23, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Timotheos is correct, and it is this variable --
$results['attributes']
-- in your foreach loop that looks like it may possibly be the index of a database fetch, and if so, it won't be defined as an array, which in turn is giving PHP fits and you your error message. You'll need to further investigate to discover where the variable
$results
is being created...

erikcw

1:26 am on Mar 26, 2004 (gmt 0)

10+ Year Member



Thanks for your suggestions!

I've been trying to figure this thing about, but am starting to tear my hair out!

This is one of several scripts that make this app. All seem to work but this one - of course this script is a cruicial one!

Can anyone figure out what needs to be done to $results to make this thing not throw the error any more?

Instead of posting the whole script, here is a link to a .txt version

Thanks for your assistance!

[edited by: jatar_k at 3:46 am (utc) on Mar. 26, 2004]
[edit reason] no personal urls thanks [/edit]