Joseph Witchard Posted September 14, 2008 Share Posted September 14, 2008 <?php $user_id = $_GET['user_id']; // start the session session_name('pickles'); session_set_cookie_params(900); session_start(); // verify session if (empty($_SESSION) || $_SESSION['news'] != true) { // redirect them header("Location: https://uhrebirth.com/staff/admin_login.php"); exit; } // require the connection settings require_once("path_to_connection_settings); // connect to the database $conn = sdaAccess(); // write the query $query = "SELECT user_id, username, pwd, user_email FROM users WHERE user_id = ? LIMIT 1"; // prepare the statement if ($stmt = $conn->prepare($query)) { // bind the parameters $stmt->bind_param('i', $user_id); // execute if ($stmt->execute()) { $stmt->bind_result($id, $username, $pwd, $email); $stmt->fetch(); } } $stmt->close(); ?> I have my HTML below set to display all of the information from the database (for testing purposes). However, ID is displayed as 0, and nothing else is displayed. For some reason, it appears that $_GET isn't getting the appropriate information from the URL:confused: Could someone give me a hand? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted September 14, 2008 Share Posted September 14, 2008 Try to echo it out $user_id = $_GET['user_id']; echo $user_id; If that doesn't display anything, double check that "user_id" is in the URL, and is spelled correctly. Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted September 14, 2008 Share Posted September 14, 2008 if you have error_reporting set to E_ALL it will tell you if you are trying to access an index that does not exist, in this case user_id. Quote Link to comment Share on other sites More sharing options...
Joseph Witchard Posted September 14, 2008 Author Share Posted September 14, 2008 I did an echo on $user_id, and it came out fine. For some reason, it's happening when I work with the database. Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted September 14, 2008 Share Posted September 14, 2008 well I can tell you're missing a quote at the end of your require_once().... Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted September 14, 2008 Share Posted September 14, 2008 Replace the question mark in your query $query = "SELECT user_id, username, pwd, user_email FROM users WHERE user_id = '$user_id' LIMIT 1"; Make sure the query doesn't return an error. It's hard to tell you how to find errors in your code, because you have your own database class. If it comes down to it, echo out the query and try manually putting it in phpmyadmin to see if it works. Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted September 14, 2008 Share Posted September 14, 2008 Replace the question mark in your query $query = "SELECT user_id, username, pwd, user_email FROM users WHERE user_id = '$user_id' LIMIT 1"; Make sure the query doesn't return an error. It's hard to tell you how to find errors in your code, because you have your own database class. If it comes down to it, echo out the query and try manually putting it in phpmyadmin to see if it works. I'm pretty sure he's using prepared statements, which in this case, his syntax would be okay (assuming he's using his library right, I don't know if he is). Quote Link to comment Share on other sites More sharing options...
Joseph Witchard Posted September 14, 2008 Author Share Posted September 14, 2008 I got it fixed. Turns out I was just closing $stmt too early. Thanks for jumping to my aid, everyone! I appreciate it! Quote Link to comment 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.