A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearPHP Script not returning db rows - page 1
User InfoPosts
PHP Script not returning db rows#1
$result = mysql_query("SELECT * FROM sggame");

while($row = mysql_fetch_assoc($result));
$id = $row['id'];
echo $id;
echo 'working?';

The above code simply doesn't return anything out of the db. The row name is correct and the loop runs, showing that there is something in the database. However the row is just not echoed out at all. This is code i have used a thousand time before and am rather perplexed as to why it has stopped now! Any help, as always, is much appreciated

posted date: 2008-12-11 02:35:00

Re: PHP Script not returning db rows#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-11 02:35:01

Re: PHP Script not returning db rows#3
replacewhile($row = mysql_fetch_assoc($result));with while($row = mysql_fetch_assoc($result))

posted date: 2008-12-11 02:37:00

Re: PHP Script not returning db rows#4
Cheers man, i've been staring at that for hours!

posted date: 2008-12-11 02:38:00

Re: PHP Script not returning db rows#5
No problem, this happens to everyone of us someday, I guess :)

posted date: 2008-12-11 02:39:00

Re: PHP Script not returning db rows#6
Pretty much the same reason as your last question - pesky semicolons!

posted date: 2008-12-11 02:46:00

Re: PHP Script not returning db rows#7
did this code give off a notice or warning when you where running it ? I am just curious being that the problem was the semicolon.

posted date: 2008-12-11 02:51:00

Re: PHP Script not returning db rows#8
while (condition); is the same as while (condition){}, i.e. a while loop with an empty body.

posted date: 2008-12-11 03:24:00

select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.