Re: Re: Array not supported for strings???
| From: | Jason Wong | Date: | Sat, 05 Jan 2002 12:30:20 +0000 |
| Subject: | Re: Re: Array not supported for strings??? | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-15437@lists.php.net to get a copy of this message | ||
On Saturday 05 January 2002 04:24, Andy wrote:
> Here is the full code:
>
> ###################################################
> # Get the name of the country:
>
> if (isset($country_id)){ //only if there are results
>
> for($i=0; $i< count($country_id); $i++){
> $stmt= "
> SELECT country
> from $DB2.$geo_T1
> where country_code = '$country_id[$i]'
> ";
>
> if ( !($result = execute_stmt($stmt, $link) )){
> HEADER("Location:empty");
> }
>
> while ($row = mysql_fetch_object($result)){
> //$country[] = $row->country;
> };
> };
> };
> ###################################################
> "Andy" <news.letters@gmx.de> schrieb im Newsbeitrag
> news:20020104200107.90859.qmail@pb1.pair.com...
>
> > Hi there,
> >
> > I have a problem with an array:
> >
> > This code:
> > $country[] = $row->country;
> >
> > Creates following error msg:
> > Fatal error: [] operator not supported for strings
> >
> > The wired thing is, that the same procedure works through my whole
> > application, but not in this case.
> >
> > Did anybody make the same experience?
You've probably used $country before in a string context. Just reset it to
some known state before your while loop:
unset($country); OR
$country="";
should do the trick.
hth
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
/*
"I'd love to go out with you, but I'm converting my calendar watch from
Julian to Gregorian."
*/