DootThaLoop Posted May 14, 2008 Share Posted May 14, 2008 I'm kind of new to PHP. So this has been puzzling me. I am trying to make a script to display users online. So far, so good, but I need to know how to put spaces in between each users name on the row. Here is the error I get when I try to do that: Parse error: syntax error, unexpected T_ECHO, expecting T_WHILE in /home/helloism/public_html/ynw/login/users.php on line 46 And here is the snippet of code I'm using. If you need to see more of or the entire code, let me know: if (isset($row_online['username'])) { do echo ($row_online['username'].""); echo '<br>'; } while($row_online = mysql_fetch_assoc($online)); I already know that this is the problem-causing line, so no big suprise: echo '<br>'; So I need help... can I somehow put both echos together, or what? Thanks for looking! Quote Link to comment https://forums.phpfreaks.com/topic/105671-solved-putting-ltbrgt-after-each-record/ Share on other sites More sharing options...
Jazzua Posted May 14, 2008 Share Posted May 14, 2008 Hey there doot, I'm also new to php. I haven't yet used a do while loop in php but have in java/c++. I might be totally wrong but shouldn't the closing curly brace of the if statement be after the while statement? like: if (isset($row_online['username'])) { do { echo ($row_online['username'].""); echo '<br>'; } while($row_online = mysql_fetch_assoc($online)); } hope that helps ~ Jazz Quote Link to comment https://forums.phpfreaks.com/topic/105671-solved-putting-ltbrgt-after-each-record/#findComment-541408 Share on other sites More sharing options...
MadTechie Posted May 14, 2008 Share Posted May 14, 2008 Jazz is correct but as your using mysql_fetch_assoc, you want the while without the do, as if no records are found your get errors <?php if (isset($row_online['username'])) { while($row_online = mysql_fetch_assoc($online)) { echo ($row_online['username'].""); echo '<br>'; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/105671-solved-putting-ltbrgt-after-each-record/#findComment-541412 Share on other sites More sharing options...
DootThaLoop Posted May 15, 2008 Author Share Posted May 15, 2008 Thanks that really did the trick Quote Link to comment https://forums.phpfreaks.com/topic/105671-solved-putting-ltbrgt-after-each-record/#findComment-541435 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.