Jump to content

SELECT FROM only returning first 74 entrys


Go to solution Solved by dlan1,

Recommended Posts

I am using a simple membership on my site. I'm a cut and paste expert not a programer. I was able to get it working, It worked fine till I got over 100 members. Now it is only finding the first 74

 

So if I use;

 

$sql="SELECT * FROM users WHERE email_address = 'me@you.com' "; 

 

It will only find me@you.com  if it is one of the first 74 records.

 

I'm sure there is something I don't know that is causeing the problem, Just don't know what.

 

If someone could point me to the right direction I'd be greatfull.

 

Thanks, Don..

 

 

MySQL 5.5

CREATE TABLE IF NOT EXISTS `users` (
  `userid` int(10) NOT NULL AUTO_INCREMENT,
  `first_name` varchar(25) NOT NULL DEFAULT '',
  `last_name` varchar(25) NOT NULL DEFAULT '',
  `email_address` varchar(45) NOT NULL,
  `password` varchar(10) NOT NULL DEFAULT '',
  `zipcode` varchar(11) NOT NULL,
  `user_level` enum('0','1','2','3') NOT NULL DEFAULT '0',
  `signup_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `last_login` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `activated` enum('0','1') NOT NULL DEFAULT '0',
  `userIP` varchar(20) NOT NULL,
  PRIMARY KEY (`userid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COMMENT='Membership Information' AUTO_INCREMENT=115 ;

you are going to need to troubleshoot the problem to narrow it down. either the data being stored in your table isn't what you think (has white-space/non-printing characters as part of it so it doesn't match what the query is using) or your code forming that query, running it, and displaying the result contains a problem.

 

how are your email values getting inserted into the table (some type of csv import or a registration form)? is the code filtering/validating them so that you know they don't contain any extra white-space/non-printing characters?

 

what's your full code from the point of inputting/selecting the email address (a form/dropdown menu...) through to the end of the code that is telling you the email address doesn't exist?

This started when I received an email saying that someone could not log-in. They were a message Account not active.

I looked in DB file and it should have been ok.. FYI, the site is ohioeuchre.com

 

I've been testing using a page that just lists all members. If  I select using 'userID'  it will show the complete list. however if I Cut+P directly from a membership list, ( using the WHERE email_address statement ) sometimes it will work and somedtimes not. This page and the actual that is used in the membership program(chenckuser.php)  both do the same thing. some thing will work some won't.

 

I may have been wrong with the 74 number. This morming I found some higher records that it would find..

 

The php error log show nothing

 

This is the test page:

 

    <?php

    // Connection to the database
    include 'inc/db_connect.php';
    
    //$sql="SELECT * FROM users ORDER BY userid";
    
    $sql="SELECT * FROM users WHERE email_address = 'me@you.com' ";
    $result=mysql_query($sql);

    // Start of html that is displayed
    ?>
    
<div align="center">
<div id="textbox">

<h2>OhioEuchre.Com Membership List</h2><br>
<table  border="1" cellpadding="3" cellspacing="1">
<?$num = 0;?>
<tr bgcolor="<?=(++$num%2==0 ? "#E6D78E" : "#dcc55d")?>">
<td align="center" width="20"><strong>Count</strong></td>
<td align="center" width="20"><strong>ID #</strong></td>
<td align="center" width="60"><strong> First Name</strong></td>
<td align="center" width="120"><strong>Email</strong></td>
<td align="center" width="20"><strong>Zip Code</strong></td>
<td align="center" width="20"><strong>Activated</strong></td>
<td align="center" width="20"><strong>Password</strong></td>

</tr>

<?php
$Count = 1;
while($rows=mysql_fetch_array($result)){
?>
<tr bgcolor="<?=(++$num%2==0 ? "#E6D78E" : "#dcc55d")?>">
<td align="center"><? echo $Count++; ?></td>
<td align="center"><? echo $rows['userid']; ?></td>
<td align="left"><? echo $rows['first_name']; ?></td>
<td align="center"><? echo $rows['email_address']; ?></td>
<td align="center"><? echo $rows['zipcode']; ?></td>
<td align="center"><? echo $rows['activated']; ?></td>
<td align="center"><? echo $rows['password']; ?></td>
</tr>

<?php } ?>
 </table>

 

END OF TEST PAGE.................

Anybody have any thoughts on this?

 

I've been playing with this for days now and I keep coming up with the same results. I created a new DB dumped the table from the old one and inserted it into new DB

 

Tried query directly in phpMyadim SQL  using the statment  SELECT email_address FROM users WHERE email_address = 'me@you.com'   where 'me@you' is replaced with  emails cut directly from a browse listing.  Again some emails will show a result and some will show zero return.

 

It makes no sense to me and I'm out of ideas or things to try.

So phpMyAdmin is also not showing the correct results?

 

to me that sounds like some email address stored in the email_address field may also contain some extra characters, such as white space (spaces, newlines etc), before and/or after the users email address which is causing the WHERE clause to fail.

I've tried cut and paste, I've tried typing the email into the myphpAdmin statement. Nothing works. It seems that your saying what I've got should work.  I think my next step is file a ticket with BlueHost.com (they host the site) and see if the problem is with something on their end.

 

Thanks for your time...

Don

the problem's not very likely anything to do with your web host. two people have suggested the symptom is due to non-printing/white-space characters that are stored in the database table. you were even asked specifically how the data got inserted into the table and if the code doing that was validating the data -

 

 

how are your email values getting inserted into the table (some type of csv import or a registration form)? is the code filtering/validating them so that you know they don't contain any extra white-space/non-printing characters?

 

  • Solution

Ok, sorry, I guess I didn't understand what was being said about white spaces, and yes that was the problem. As I went back and looked at the file I dumped and there they were. I didn't mean to be a thick head.

 

Thanks for putting up with me.

 

Don...

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.