Search the Community
Showing results for tags 'mysqli query'.
-
My code here works in some locations but not others. I believe it may be due to a faulty database connection. The $dbconnection gets returned from a function intended for the purpose and then passed to functions as needed. I am getting this error message for a $conn->query("SELECT * FROM formstable"); : (The warning goes on to specify the page and line number of course.) The code works within the database connection function just before my "return $conn;" statement. It works within a function "askQuery" called from one location but not anorher. It does not work at all in a function "showSelect". This seems the most relevant code: $newsqlStatement = showSelect($testConn, "SELECT * FROM formstable"); // will later isolate selectStatement WHERE formname = formname function showSelect($conn, $sqlStatement) { $result = $conn->query("SELECT * FROM formstable"); . ' ' return $successSelect; // for now just true or false } // end function showSelect
-
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>