phprocker Posted October 30, 2010 Share Posted October 30, 2010 I'm a bit stumped here and as usual I'm sure it's something simple. I have an object that checks if a user is an admin. It works fine. But it the HTML below it is not getting displayed. Take a look. welcome.php session_start(); $user = new users(); if (!isset($_SESSION['username'], $_SESSION['imadmin']) || $user->is_admin($_SESSION['username'])==0) { header('Location: index.php'); } welcome.php is getting displayed without getting redirected to the index. But there's no HTML, just the URL to welcome.php in the bar. Anyone? Cheers! Quote Link to comment https://forums.phpfreaks.com/topic/217280-welcome-page-shows-but-not-html/ Share on other sites More sharing options...
kenrbnsn Posted October 30, 2010 Share Posted October 30, 2010 Please post the rest of the code. Ken Quote Link to comment https://forums.phpfreaks.com/topic/217280-welcome-page-shows-but-not-html/#findComment-1128314 Share on other sites More sharing options...
Pikachu2000 Posted October 30, 2010 Share Posted October 30, 2010 So there's nothing there when you do a View Source? Quote Link to comment https://forums.phpfreaks.com/topic/217280-welcome-page-shows-but-not-html/#findComment-1128315 Share on other sites More sharing options...
phprocker Posted October 30, 2010 Author Share Posted October 30, 2010 So there's nothing there when you do a View Source? No. I thought it was because I wasn't including the classes.php file but I added that and still same thing. I have to get to sleep, thanks for looking. I'll try again in the morning and post the rest of the code when I can take a look at it through non-bloodshot eyes. Cheers people thanks! Quote Link to comment https://forums.phpfreaks.com/topic/217280-welcome-page-shows-but-not-html/#findComment-1128316 Share on other sites More sharing options...
PFMaBiSmAd Posted October 30, 2010 Share Posted October 30, 2010 I'll guess a fatal parse or fatal runtime error, due to something in the code that was not posted. Are you doing this on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that all the php errors that your code produces would be reported and displayed? You will save a ton of time. Quote Link to comment https://forums.phpfreaks.com/topic/217280-welcome-page-shows-but-not-html/#findComment-1128317 Share on other sites More sharing options...
phprocker Posted October 30, 2010 Author Share Posted October 30, 2010 Ya I had errors off which was extremely stupid. I turned it off for another project. Anyway, here's the error. error on welcome.php Fatal error: Call to a member function query() on a non-object in C:\xampp\htdocs\site\classes.php on line 24 Code: classes.php class users { function is_admin($username) { global $mysqli; $result = $mysqli->query("SELECT isadmin FROM users WHERE username = '$username'"); $value = $result->fetch_object(); if ($value->isadmin == 1) { return 1; } return 0; } } welcome.php <?php session_start(); include 'root.php'; include ROOT.DS.'classes.php'; $user = new users(); if (!isset($_SESSION['username'], $_SESSION['imadmin']) || $user->is_admin($_SESSION['username'])==0) { header('Location: index.php'); } ?> //the rest is all html Quote Link to comment https://forums.phpfreaks.com/topic/217280-welcome-page-shows-but-not-html/#findComment-1128403 Share on other sites More sharing options...
BlueSkyIS Posted October 30, 2010 Share Posted October 30, 2010 Fatal error: Call to a member function query() on a non-object in C:\xampp\htdocs\site\classes.php on line 24 The function query() is being called, but on a non-object, mysqli. Where do you set mysqli, and is it declared global outside of the users class? Quote Link to comment https://forums.phpfreaks.com/topic/217280-welcome-page-shows-but-not-html/#findComment-1128407 Share on other sites More sharing options...
phprocker Posted October 30, 2010 Author Share Posted October 30, 2010 Where do you set mysqli, and is it declared global outside of the users class? Ah you may have the answer. I didn't include that. It's in config.php Let me include and see if that works. Cheers! Quote Link to comment https://forums.phpfreaks.com/topic/217280-welcome-page-shows-but-not-html/#findComment-1128409 Share on other sites More sharing options...
phprocker Posted October 30, 2010 Author Share Posted October 30, 2010 It worked BlueSkyIS thanks much. Quote Link to comment https://forums.phpfreaks.com/topic/217280-welcome-page-shows-but-not-html/#findComment-1128410 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.