MySQL only returns { first row } from the result of query ! [closed]
I've used my server for testing PHP & MySQL Applications long time ago.
Suddenly, When i try to execute any query on the any table in any database, i get only the first row in the result of the query !
I checked the configuration file,开发者_运维技巧 and didn't see anything strange there.
OS: Linux / Ubuntu 10.04 64bit Server Edition, Web Server: Apache/2.2.14, MySQL Client: 5.1.41, MySQL Server: 5.1.41-3ubuntu12.3 (Ubuntu)
And, I'm sure that there's no error in my PHP Code, While when i use phpMyAdmin, i get all rows normally !.
Where should be the problem ?
It would help if you posted your code, but I'm guessing that your code doesn't have a loop that fetches each row.
<?php
$Result = mysql_query( $Query );
while( $Row = mysql_fetch_assoc( $Result ) ) //keep going while there are more rows
{
print_r( $Row );
}
mysql_fetch_accoc and mysql_fetch_array functions only return one row at a time (consecutively) so you need to run them for each row.
The problem is with your code. You have just told us that phpMyAdmin returns from MySql fine, so clearly the MySql server is not the problem, nor is any part of the PHP server setup.
Your code is wrong, you probably have (inside your super confidential and perfect code) a limit 1 in your staement, or are grabbing the rows incorrectly because you are unaware of how mysql_fetch functions work.
Downvote me because I'm a snarky jerk, but whatever.
精彩评论