开发者

MySQL only returns { first row } from the result of query ! [closed]

开发者 https://www.devze.com 2023-01-05 08:03 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号