Jump to content

Query suddenly not returning all results


Recommended Posts

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.

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.