Re: [PHP] list($bar['CompanyCode'], $CompanyDB) = mysql_fetch_row($sth) fails.

2004-07-29 Thread Matthew Sims
 Why does this fail when using an array element, but using a variable will
 work? Why should PHP care what the variable is I'm trying to store into?

 list($bar['CompanyCode'], $CompanyDB) = mysql_fetch_row($sth);

Wouldn't it be easier to simply do:

$result = mysql_fetch_row($sth);

And then work with the $result array? If your DB indexes are listed as
CompanyCode and CompanyDB, then use:

$result = mysql_fetch_array($sth);

Then you have your variable names like you want:

$result['CompanyCode'] and $result['CompanyDB']

-- 
--Matthew Sims
--http://killermookie.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] list($bar['CompanyCode'], $CompanyDB) = mysql_fetch_row($sth) fails.

2004-07-28 Thread Justin Patrin
On Wed, 28 Jul 2004 20:47:37 -0700, Daevid Vincent [EMAIL PROTECTED] wrote:
 Linux. PHP5.
 
 Why does this fail when using an array element, but using a variable will
 work? Why should PHP care what the variable is I'm trying to store into?
 
 list($bar['CompanyCode'], $CompanyDB) = mysql_fetch_row($sth);
 
 But this works:
 
 list($foo, $CompanyDB) = SQL_ROW($sth);
 
 And of course I'd have the extra...
 $foo = $bar['CompanyCode'];
 

Because list() is a language construct, not a function. It assumes
what you give it is a normal variable, it doesn't understand arrays.

Better IMHO to use $row = mysql_fetch_assoc() and access the array it
returns directly.

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] list($bar['CompanyCode'], $CompanyDB) = mysql_fetch_row($sth) fails.

2004-07-28 Thread Jason Davidson
check the manual for list.  It mentions using only numerical array
indices for list.  There is a warning on it even i beleive.

Jason

On Wed, 28 Jul 2004 20:47:37 -0700, Daevid Vincent [EMAIL PROTECTED] wrote:
 Linux. PHP5.
 
 Why does this fail when using an array element, but using a variable will
 work? Why should PHP care what the variable is I'm trying to store into?
 
 list($bar['CompanyCode'], $CompanyDB) = mysql_fetch_row($sth);
 
 But this works:
 
 list($foo, $CompanyDB) = SQL_ROW($sth);
 
 And of course I'd have the extra...
 $foo = $bar['CompanyCode'];
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php