Lamez Posted September 21, 2008 Share Posted September 21, 2008 Ok so I have a website's statistics page, and if one of the query is empty, it does not display any of the page. I am wondering how to fix this, here is the code: <?php $path = ""; $title = "Website's Statistics"; $rank = "yes"; $ban = "yes"; include ($path."main/include/cons/head.php"); $tot_usr = mysql_query("SELECT * FROM `users`")or die(mysql_error()); $tot_usr = mysql_num_rows($tot_usr)or die(mysql_error()); $banned = mysql_query("SELECT * FROM `users` WHERE `ban` = '1'")or die(mysql_error()); $banned = mysql_num_rows($banned)or die(mysql_error()); $admins = mysql_query("SELECT * FROM `users` WHERE `userlevel` = '9'") or die(mysql_error()); $admins = mysql_num_rows($admins)or die(mysql_error()); $members = mysql_query("SELECT * FROM `users` WHERE `userlevel` = '1'") or die(mysql_error()); $members = mysql_num_rows($members)or die(mysql_error()); $tot_pms = mysql_query("SELECT * FROM `messages` WHERE `id` >= 0") or die(mysql_error()); $tot_pms = mysql_num_rows($tot_pms) or die(mysql_error()); $un_pm = mysql_query("SELECT * FROM `messages` WHERE `recieved` = '0'")or die(mysql_error()); $un_pm = mysql_num_rows($un_pm) or die(mysql_error()); $re_pm = mysql_query("SELECT * FROM `messages` WHERE `recieved` = '1'")or die(mysql_error()); $re_pm = mysql_num_rows($re_pm) or die(mysql_error()); $top = mysql_query("SELECT * FROM `forum_question`")or die(mysql_error()); $top = mysql_num_rows($top) or die(mysql_error()); $res = mysql_query("SELECT * FROM `forum_answer`")or die(mysql_error()); $res = mysql_num_rows($res) or die(mysql_error()); echo' <p class="header">Website\'s Statistics</p> <p class="maintext"> <b>Total Users</b>: '.$tot_usr.' <br /> <b>Total Banned Users</b>: '.$banned.' <br /> <b>Total Admins</b>: '.$admins.' <br /> <b>Total Members</b>: '.$members.' <br /><br /> <b>Website Status</b>: '.$site_stat.' <br /><br /> <b>Total PMs</b>: '.$tot_pms.' <br /> <b>Total Unread PMs</b>: '.$un_pm.' <br /> <b>Total Read PMs</b>: '.$re_pm.' <br /><br /> <b>Total Forum Topics</b>: '.$top.' <br /> <b>Total Forum Responses</b>: '.$res.' </p>'; include ($path."main/include/cons/foot.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/125146-solved-page-ends-when-query-is-empty/ Share on other sites More sharing options...
redarrow Posted September 21, 2008 Share Posted September 21, 2008 try OR NULL on all the selects mate example only $banned = mysql_query("SELECT * FROM `users` WHERE `ban` = '1' OR NULL")or die(mysql_error()); $banned = mysql_num_rows($banned)or die(mysql_error()); maybe this is correct $banned = mysql_query("SELECT * FROM `users` WHERE `ban` = '1' AND `ban`= NULL")or die(mysql_error()); $banned = mysql_num_rows($banned)or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/125146-solved-page-ends-when-query-is-empty/#findComment-646818 Share on other sites More sharing options...
Lamez Posted September 21, 2008 Author Share Posted September 21, 2008 wow thanks, now could I add or die as well!? Quote Link to comment https://forums.phpfreaks.com/topic/125146-solved-page-ends-when-query-is-empty/#findComment-646819 Share on other sites More sharing options...
redarrow Posted September 21, 2008 Share Posted September 21, 2008 yes did it work Quote Link to comment https://forums.phpfreaks.com/topic/125146-solved-page-ends-when-query-is-empty/#findComment-646820 Share on other sites More sharing options...
Lamez Posted September 21, 2008 Author Share Posted September 21, 2008 yes this is the code I am using.. <?php $path = ""; $title = "Website's Statistics"; $rank = "yes"; include ($path."main/include/cons/head.php"); $tot_usr = mysql_query("SELECT * FROM `users`")or NULL; $tot_usr = mysql_num_rows($tot_usr)or NULL; $banned = mysql_query("SELECT * FROM `users` WHERE `ban` = '1'")or NULL; $banned = mysql_num_rows($banned)or NULL; $admins = mysql_query("SELECT * FROM `users` WHERE `userlevel` = '9'") or NULL; $admins = mysql_num_rows($admins)or NULL; $members = mysql_query("SELECT * FROM `users` WHERE `userlevel` = '1'") or NULL; $members = mysql_num_rows($members)or NULL; $tot_pms = mysql_query("SELECT * FROM `messages` WHERE `id` >= 0") or NULL; $tot_pms = mysql_num_rows($tot_pms) or NULL; $un_pm = mysql_query("SELECT * FROM `messages` WHERE `recieved` = '0'")or NULL; $un_pm = mysql_num_rows($un_pm) or NULL; $re_pm = mysql_query("SELECT * FROM `messages` WHERE `recieved` = '1'")or NULL; $re_pm = mysql_num_rows($re_pm) or NULL; $top = mysql_query("SELECT * FROM `forum_question`")or NULL; $top = mysql_num_rows($top) or NULL; $res = mysql_query("SELECT * FROM `forum_answer`")or NULL; $res = mysql_num_rows($res) or NULL; echo' <p class="header">Website\'s Statistics</p> <p class="maintext"> <b>Total Users</b>: '.$tot_usr.' <br /> <b>Total Banned Users</b>: '.$banned.' <br /> <b>Total Admins</b>: '.$admins.' <br /> <b>Total Members</b>: '.$members.' <br /><br /> <b>Website Status</b>: '.$site_stat.' <br /><br /> <b>Total PMs</b>: '.$tot_pms.' <br /> <b>Total Unread PMs</b>: '.$un_pm.' <br /> <b>Total Read PMs</b>: '.$re_pm.' <br /><br /> <b>Total Forum Topics</b>: '.$top.' <br /> <b>Total Forum Responses</b>: '.$res.' </p>'; include ($path."main/include/cons/foot.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/125146-solved-page-ends-when-query-is-empty/#findComment-646821 Share on other sites More sharing options...
redarrow Posted September 21, 2008 Share Posted September 21, 2008 good stuff mate looks good........... Quote Link to comment https://forums.phpfreaks.com/topic/125146-solved-page-ends-when-query-is-empty/#findComment-646823 Share on other sites More sharing options...
Lamez Posted September 21, 2008 Author Share Posted September 21, 2008 thanks! Quote Link to comment https://forums.phpfreaks.com/topic/125146-solved-page-ends-when-query-is-empty/#findComment-646825 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.