Re: [PHP4BETA] select from.... - strange result
| From: | Sterling Hughes | Date: | Sat, 25 Mar 2000 01:34:21 +0000 |
| Subject: | Re: [PHP4BETA] select from.... - strange result | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-12584@lists.php.net to get a copy of this message | ||
Martin Samesch wrote:
> Hi,
>
> could this be a bug:
>
> With
>
> ---snip---
> $table = "Species";
> $condition = "gattung='g13' && art='a13' &&
> u_art='ua13'";
> $query = "SELECT spec_id FROM $table WHERE $condition";
> $result = @mysql_db_query($database,$query);
> $row = mysql_fetch_array($result);
> var_dump($row);
> ---snip---
>
> var_dump($row) produces
>
> array(2) { [0]=> string(1) "6" ["spec_id"]=> string(1)
> "6" }
>
> whereas on the commandline with
>
> mysql> select spec_id from Species where gattung='g13' &&
> art='a13' && u_art='ua13';
>
> I get the expected result:
>
> +---------+
> | spec_id |
> +---------+
> | 6 |
> +---------+
> 1 row in set (0.01 sec)
>
> Where could this [0]=> string(1) "6" come from?
>
This isn't a bug, rather a feature, mysql_fetch_array returns an array the can
either be accessed by a numerical index or a string index.
Cheers,
Sterling Hughes
sterling@designmultimedia.com