Database Not Echoing Properly

Place for questions and answers for all newcomers and new coders. This is a free for all forum, no question is too stupid and to noob.
Post Reply
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Database Not Echoing Properly

Post by Epiales »

I've spent a few hours and I can't figure out the error. It's so darn simple it's hard :lol: :lol: :lol: :lol:

Why won't it echo the database?

Image
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: Database Not Echoing Properly

Post by Jackolantern »

If even your test echo is not printing, that means your WHILE loop isn't running. I would start investigating there to see what you are actually getting into the $row. If $row is empty the first time the WHILE runs, it will be skipped.
The indelible lord of tl;dr
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Database Not Echoing Properly

Post by Epiales »

Jackolantern wrote:If even your test echo is not printing, that means your WHILE loop isn't running. I would start investigating there to see what you are actually getting into the $row. If $row is empty the first time the WHILE runs, it will be skipped.
Well if I take this out of the file:

Code: Select all

while ($row = mysqli_fetch_array($user_query, MYSQLI_ASSOC)) {
Then it will display the first item and all its rows but not the other items. Only the first one. For some reason, the while is just not working and it doesn't make sense. It even displays the items picture, but only for the first item, and if I put the while back in, it removes it all except the headers I created above.

This is the actual echo statement I use to list the items:

Code: Select all

echo "<tr align='left'><td><img src = '".$row['image']."'height='100' width='100'></td><td>$row[name]</td><td>$row[strength]</td><td>$row[defense]</td><td>$row[price]</td><td><A href='buy_item.php?randid=$row[randid]'><font color='red'>Buy Item</font></td></tr>";
So in otherwords, my echo is written correctly, because when I remove the while loop, it does echo the first row in the database, but not the other rows. We need a pull u're hair out emoticon :D :D :D
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
Epiales
Posts: 1119
Joined: Thu Aug 15, 2013 1:38 am

Re: Database Not Echoing Properly

Post by Epiales »

Oh Lord.... I had for location : United States..... it's supposed to be United States of America :D :D :D :D :D

Thanks for telling me to further dig into the while and see the rows.
Nothing fancy, but a work in progress!

http://gameplaytoday.net
User avatar
Jackolantern
Posts: 10893
Joined: Wed Jul 01, 2009 11:00 pm

Re: Database Not Echoing Properly

Post by Jackolantern »

No problem! Glad you fixed it :)
The indelible lord of tl;dr
Post Reply

Return to “Beginner Help and Support”