nowuseeme Posted July 16, 2013 Share Posted July 16, 2013 hey guys, anyone have any idea why i cant get my code to show the results when i click submit? thanks. <?php require("db.php"); $data = array(); if(!empty($_GET['term'])) { $query = "SELECT department, subject, message FROM supporttickets WHERE ticketnumber = ?"; $stmt = $db->prepare($query); $stmt->execute(array($_GET['term'])); $data = $stmt->fetchAll(); } foreach ($data as $row) { echo htmlspecialchars($row['department']); } if (!$data) { echo "Please enter valid Ticket Number."; } Link to comment https://forums.phpfreaks.com/topic/280209-not-showing-results/ Share on other sites More sharing options...
fastsol Posted July 16, 2013 Share Posted July 16, 2013 Do you have error reporting turned on? What do you get if you do a print_r($data); Are you sure the query isn't failing? Link to comment https://forums.phpfreaks.com/topic/280209-not-showing-results/#findComment-1440936 Share on other sites More sharing options...
nowuseeme Posted July 16, 2013 Author Share Posted July 16, 2013 Do you have error reporting turned on? What do you get if you do a print_r($data); Are you sure the query isn't failing? Hi i have error reporting on im not getting any errors at all, for print_r($data); im also not getting anything the only thing that is showing is (Please enter valid Ticket Number.) and that is showing all the time thanks. Link to comment https://forums.phpfreaks.com/topic/280209-not-showing-results/#findComment-1440937 Share on other sites More sharing options...
fastsol Posted July 16, 2013 Share Posted July 16, 2013 Ok well then you're not getting any results from the query or the query is failing. You need to start diagnosing that part first. Link to comment https://forums.phpfreaks.com/topic/280209-not-showing-results/#findComment-1440939 Share on other sites More sharing options...
nowuseeme Posted July 16, 2013 Author Share Posted July 16, 2013 Ok well then you're not getting any results from the query or the query is failing. You need to start diagnosing that part first. Ok so i changed the $_GET TO $_POST and now it's working does that seem right? Link to comment https://forums.phpfreaks.com/topic/280209-not-showing-results/#findComment-1440940 Share on other sites More sharing options...
fastsol Posted July 16, 2013 Share Posted July 16, 2013 No idea, you didn't show us how you were getting the value of ['term'] to the page in the first place. So $_POST could be correct if you're using a form to send that data and the form method is set to "post". Link to comment https://forums.phpfreaks.com/topic/280209-not-showing-results/#findComment-1440942 Share on other sites More sharing options...
nowuseeme Posted July 16, 2013 Author Share Posted July 16, 2013 Ok got it thanks for the help! Link to comment https://forums.phpfreaks.com/topic/280209-not-showing-results/#findComment-1440944 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.