ronnie88 Posted July 23, 2008 Share Posted July 23, 2008 I'm sure this has been answered before but couldn't find it Its giving me an error if the mysql field is empty im using it for this script... <? $query = "SELECT va, cash FROM users WHERE username='{$_SESSION['username']}'"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { echo "{$row['va']} <br>" . "Cash : {$row['cash']} <br>" . "Flight's Available : {$row['flights']} <br>"; ?> Any Help would be appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/116142-solved-empty-mysql-gives-error/ Share on other sites More sharing options...
MasterACE14 Posted July 23, 2008 Share Posted July 23, 2008 try changing it to this and see what happens... <?php if(isset($_SESSION['username']) && !empty($_SESSION['username'])) { $query = "SELECT va, cash FROM users WHERE username='{$_SESSION['username']}'"; $result = mysql_query($query) or die("There was a Error: ".mysql_error()); while($row = mysql_fetch_assoc($result)) { echo "{$row['va']} <br>" . "Cash : {$row['cash']} <br>" . "Flight's Available : {$row['flights']} <br>"; } } else { echo "Username is not set!"; } ?> Regards ACE Quote Link to comment https://forums.phpfreaks.com/topic/116142-solved-empty-mysql-gives-error/#findComment-597248 Share on other sites More sharing options...
ronnie88 Posted July 23, 2008 Author Share Posted July 23, 2008 tyvm Quote Link to comment https://forums.phpfreaks.com/topic/116142-solved-empty-mysql-gives-error/#findComment-597249 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.