Easy while loop question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mikusan
Forum Contributor
Posts: 247
Joined: Thu May 01, 2003 1:48 pm

Easy while loop question

Post by mikusan »

Hi, this is probably real dumb...
but here i go anyways...

Code: Select all

$SQL = mysql_query("SELECT anything FROM sometable ORDER BY uid DESC LIMIT 10"); 

while( $Data = mysql_fetch_assoc($SQL) ) {
echo('Why wont you work');
}
The echo does not display.... Ironically i used this peice of code before an it worked... am i doing something stupid here or is it somewhere else?
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

heres what you have to do

say you want to echo "something from "sometable", you would do this

echo $Data['something'];

that should do the trick...
User avatar
mikusan
Forum Contributor
Posts: 247
Joined: Thu May 01, 2003 1:48 pm

Post by mikusan »

The thing is that it does not get there... so it doesn't matter what i echo... it just doesn't get there.
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

can you show me all of your code...perhaps your problem lies earilier in the script
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

Are you sure the query is working? Try using this line to see if the query is working or not:

Code: Select all

<?php
$SQL = mysql_query("SELECT anything FROM sometable ORDER BY uid DESC LIMIT 10") or die(mysql_error());
?>
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

i was just figuring that there was not a positive connection.....but W/E
User avatar
mikusan
Forum Contributor
Posts: 247
Joined: Thu May 01, 2003 1:48 pm

Post by mikusan »

That was really dumb... thank you very much DuFF

I added that error and i knew exactly what was wrong... DOH... i wish my server had error set to E_all

Bah... thanks
Post Reply