Re: assign value from fetch array
| From: | Ricardo R Bonfim | Date: | Tue, 20 May 2014 03:03:06 +0000 |
| Subject: | Re: assign value from fetch array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-323348@lists.php.net to get a copy of this message | ||
If I got it correctly, you're using PDO and using Statement fetchAll
method, which would return an array of arrays.
Your variable $row would fit best as $rows if you know what I mean...
try to iterate over the return of fetchAll and give it a print to see
how it looks like.
2014-05-19 20:57 GMT-03:00 ICCSI <inungh@gmail.com>:
> I have following code to fetch data from database.
> I am able to print the array, but I got HTTP 500 error when I assign the
> array the value to echo the result.
>
> I think I am missing something between array and variable.
>
> Your help and information is great appreciated,
>
> Iccsi,
>
>
> $row = $sth->fetchAll(PDO::FETCH_ASSOC);
> print_r($row);
> print("\n");
> $name = "{$row['MyID']}";
> echo $name;
--
Att,
____________________________________________________
Ricardo R Bonfim