OnTarget600
-
Posts
2 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Downloads
Gallery
Store
Posts posted by OnTarget600
-
-
Hello,
Continuing from the code above I am getting a notice. It still outputs the results after the notice. The notice line number suggests that it is this line:
$my_rows = $my_rows. "Name : {$row['name']}
" . "id : {$row['id']}
";I receive this error:
Notice: Undefined variable: my_rows in /srv/www/htdocs/killerphp/database.php on line 23
If I remove the second $my_rows variable the error goes away but so does the code functionality by only outputting the first db entry.
I am using a standard LAMP stack with php 5.2.9
Any ideas of why and if there is replacement code?
Questions from a mysql tutorial video.
in PHP
Posted
Thanks for you quick reply. Unfortunatly it appears the curly brace "{}" are meant to be. I changed them as per your suggestion and it broke completely. Eclipse also reports a syntax error when they are changed. I wont post the error as I don't want to confuse the issue. Here is the full code.
$query = "SELECT * FROM people";
$result = mysql_query($query);
$my_rows;
while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
$my_rows = $my_rows. "Name : {$row['name']}
" . "id : {$row['id']}
";
}
echo $my_rows;
Thanks again.