Titan of Liquor Posted May 14, 2011 Share Posted May 14, 2011 Greetings all! I've been working on a project for about a week now and everything had been going fine until this evening. I'm querying a single row from a user information table based on the userID and doing various things based off of the information that is returned. For whatever reason, the query is not returning all of the information anymore. Code follows: $userToEdit = mysqli_real_escape_string($GLOBALS['link'], $_POST['userToEdit']); $userSQL = "SELECT fName, lName, email, volunteer, staff, admin, active, volunteerID FROM userinfo WHERE userID=" . $userToEdit; $result = mysqli_query($GLOBALS['link'], $userSQL); if (!$result) { $message = 'There was an error retrieving the user information from the database.'; include '../html/error.html.php'; exit(); } $editInfo = mysqli_fetch_assoc($result); The strange part is that the database i'm querying is located on my remote host(GoDaddy). When I run the app from my local Apache server and query the remote DB, everything works fine, however, when I upload the files to my host, not all of the information is being returned. For example, using the print_r() function while on my local host, i get: Array ( [fName] => Taylor [lName] => Hughes [email] => taylor@gmail.com [volunteer] => 1 [staff] => 0 [admin] => 0 [active] => 1 [volunteerID] => 13 ) But when I execute the app on my remote host, the print_r() function outputs: Array ( [fName] => Taylor [lName] => Hughes [email] => taylor@gmail.com [volunteer] => [staff] => [admin] => [active] => [volunteerID] => 13 ) I'm not sure why this is happening but it is affecting multiple queries and subsequently multiple forms and functionality in different parts of the application. Any thoughts or suggestions would be greatly appreciated. I've browsed around for about an hour with no luck. I'm writing in PHP 5.3 and the remote MySQL DB is version 5.0 Oh! And if it helps, I just came to the realization that all the items not being returned are of the BIT data type in the tables. Quote Link to comment https://forums.phpfreaks.com/topic/236382-query-suddenly-not-returning-all-results/ Share on other sites More sharing options...
wildteen88 Posted May 14, 2011 Share Posted May 14, 2011 What version are you using on localhost? If its before 5.0.3 MySQL didn't actually support bit datatypes, instead BIT(1) datatype was an alias of TINYINT(1). This is why on your localhost it is displaying 1 or 0. However on your godaddy server you must be using a newer version of MySQL which has support for Bits. I found this out by reading this artical. Maybe change the data type for the volunteer, staff, admin and active columns to TINTINT(1) rather than BIT(1). Quote Link to comment https://forums.phpfreaks.com/topic/236382-query-suddenly-not-returning-all-results/#findComment-1215325 Share on other sites More sharing options...
Titan of Liquor Posted May 14, 2011 Author Share Posted May 14, 2011 Interesting article, thank you for the link. I'm going to give that suggestion a go this morning and change the BIT valued columns to TINYINTs and see if that makes a difference. The MySQL version on my localhost is 5.1.3 but my MySQL connection string is querying my remote godaddy DB so both the local app and the remote app are hitting the same DB. Im just getting two completely different results. But the article you provided hits on some good points that I hadn't considered. I'll post back when I complete the change. Quote Link to comment https://forums.phpfreaks.com/topic/236382-query-suddenly-not-returning-all-results/#findComment-1215353 Share on other sites More sharing options...
Titan of Liquor Posted May 14, 2011 Author Share Posted May 14, 2011 That did it! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/236382-query-suddenly-not-returning-all-results/#findComment-1215369 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.