Weiss Posted October 28, 2017 Share Posted October 28, 2017 Hi. Im scratching my head trying to understand the following issue: i have a built login/signup system. after user will login he will redirect to profile.php where i have a session with all the info i need. i want to run a simple query: $result = $mysqli->query("SELECT boardid FROM connector WHERE userid='$id'"); but for some reason this line kills my script. my $mysqli is working fine in all other php pages... so i try moving this line top to bottom but wherever the page meets this line the script is dead. what am i doing wrong? <?php /* Displays user information and some useful messages */ session_start(); // Check if user is logged in using the session variable if ( $_SESSION['logged_in'] != 1 ) { $_SESSION['message'] = "You must log in before viewing your profile page!"; header("location: error.php"); } else { // Makes it easier to read $first_name = $_SESSION['first_name']; $last_name = $_SESSION['last_name']; $email = $_SESSION['email']; $active = $_SESSION['active']; $id = $_SESSION['id']; } ?> <!DOCTYPE html> <html > <head> <meta charset="UTF-8"> <title>Welcome <?= $first_name.' '.$last_name ?></title> <?php include 'css/css.html'; ?> </head> <body> <div class="form"> <h1>Welcome</h1> <h2><?php echo $first_name.' '.$last_name; ?></h2> <p><?= $email ?></p> <a href="logout.php"><button class="button button-block" name="logout"/>Log Out</button></a> </div> <div> <?php //THIS IS THE LINE THAT KILLS EVERYTHING. IF I PUT IT HERE NOTHING WILL HAPPEND, IF U PUT IT UP THE SCRIPT WILL DIE $result = $mysqli->query("SELECT boardid FROM connector WHERE userid='$id'"); ?> </div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script> </body> </html> Link to comment Share on other sites More sharing options...
dsonesuk Posted October 28, 2017 Share Posted October 28, 2017 As you have it now 'IF I PUT IT HERE NOTHING WILL HAPPEND' is exactly the result you will get! You are NOT doing anything with $result to produce anything? So I don't understand the problem correctly? 36 minutes ago, Weiss said: session_start(); Should be at the top before anything else. Link to comment Share on other sites More sharing options...
justsomeguy Posted October 30, 2017 Share Posted October 30, 2017 It doesn't look like $mysqli has been defined. And if you're not seeing an error message about that, then you either have error messages disabled or you're not checking the error log. You can display them on the page like this: ini_set('display_errors', 1); error_reporting(E_ALL); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now