php mysql error beginner

Posted by Marcelo on Stack Overflow See other posts from Stack Overflow or by Marcelo
Published on 2010-06-11T12:19:59Z Indexed on 2010/06/11 12:22 UTC
Read the original article Hit count: 162

Filed under:
|
|
|

Hi, I'm trying to print some values on the screen from a table but I having a problem, I don't know much about string, vector and array but I think that my problem is related to them.

I'm getting this on the screen

Fatal error: Cannot use [] for reading ...

My code

 $sql="SELECT * FROM $tbl_name";
 $result=mysql_query($sql) or trigger_error(mysql_error().$sql);
 while($row = mysql_fetch_array($result)){
 $DATA = $row[]; }  //line with probelm
 mysql_close();

 //html part

 <table>
 <? foreach($DATA as $row): ?>
 <tr>
 <td><?=$row['id']?></td>
 //more stuff
 </tr>
 <? endforeach ?>
 </table>

What I'm trying to do is print somevalues form a database. But I'm getting this error.

I'm sorry for any mistake in English, and thanks in advance for any help.

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql