RE: [PHP-DB] Re: Array not supported for strings???

2002-01-08 Thread Ford, Mike [LSS]

 -Original Message-
 From: Andy [mailto:[EMAIL PROTECTED]]
 Sent: 04 January 2002 20:24
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Re: Array not supported for strings???
 
 $stmt= 
   SELECT country
   from  $DB2.$geo_T1
   where country_code = '$country_id[$i]'
  ;

Well, this should be

where country_code = '${country_id[$i]}'

to be sure of doing what you want.

  This code:
  $country[] = $row-country;
 
  Creates following error msg:
Fatal error: [] operator not supported for strings

Is this error coming from PHP or your database?  And does it definitely refer to this 
particular line?

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Re: Array not supported for strings???

2002-01-05 Thread Jason Wong

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 [EMAIL PROTECTED] schrieb im Newsbeitrag
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

  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.
*/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]