Click here to Skip to main content
15,886,860 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Everything was working fine, then I kept getting 999 as the last value. I'm assuming that it sees that the 9 is bigger than the 1 in 1000. I may be wrong though. However it will not return anything over 1000. The code is posted below. Any help would be great.

PHP
$db = new PDO('mysql:host='. $host .';dbname='.$db_name, $db_username, $db_password);

   $statement = $db->prepare("select * from users where user_name = :user_name");
   $statement->execute(array(':user_name' => $user)); //change send to variable
   $row = $statement->fetch();

   ///////////////////////////////////////////////////////////////////////////////////////////////////////////

       $db2 = new PDO('mysql:host='. $host .';dbname='.$db_name_uroll, $db_username, $db_password);

   //Remove $db2 prepare
   $statement2 = "select * from `{$user}` ORDER BY bet_id DESC LIMIT 23";

   $bid = array();

   if ($stmt = $db2->query($statement2)) //PDO::query() returns a PDOStatement on success or false on failure.
   {

       //If we got a PDOStatement as a return value from PDO::Query() !!!ECHO WHILE FETCHING!!!
       while($row2 = $stmt->fetch(PDO::FETCH_ASSOC)) //This loop will keep going for as many rows as the PDOStatement returns.
       {

           $bid[] = $row2['bet_id'] ;

       }
   }
Posted
Comments
Kornfeld Eliyahu Peter 20-Jan-14 14:26pm    
Not clear - you have a LIMIT 23, which will limit your result-set to 23 rows. So what the 999 and 1000 are do here?
Member 10486100 20-Jan-14 14:58pm    
DESC LIMIT means the last 23 items. The last 23 should be 1020, 1019, 1018, etc. But it displays 999,998,997,996 etc.
Kornfeld Eliyahu Peter 20-Jan-14 14:59pm    
I see now what you mean...
What type bet_id is?
Member 10486100 20-Jan-14 15:01pm    
bigint(20) AUTO_INCREMENT
Kornfeld Eliyahu Peter 21-Jan-14 3:20am    
Christian Graus asks:
If you remove the limit, does it return the right data ( albeit too much ) ? I do think a string comparison is the issue.

If you are using the MySQL Workbench it is limiting the number of rows to 1000.
You can change this setting under Edit -> Preferences.
 
Share this answer
 
Comments
Kornfeld Eliyahu Peter 21-Jan-14 3:07am    
Good thinking - however he posted code, that gets only 23 rows and no talking about WB...
I am guessing that bet_id is a string, and so a string comparison is occurring instead of a numeric one ?
 
Share this answer
 
Comments
Kornfeld Eliyahu Peter 21-Jan-14 3:06am    
See his comment on my question - that not the case...
Christian Graus 21-Jan-14 3:16am    
If you remove the limit, does it return the right data ( albeit too much ) ? I do think a string comparison is the issue.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900