mysql_fetch_array returns duplicate data

前端 未结 7 1467
谎友^
谎友^ 2020-12-02 00:25

every time i run mysql_fetch_array an array is returned with duplicate values e.g.

Array
(
    [0] => 1
    [row_id] => 1
    [1] =>         


        
7条回答
  •  半阙折子戏
    2020-12-02 01:10

    From the manual:

    Returns an array of strings that corresponds to the fetched row, or FALSE if there are no more rows. The type of returned array depends on how result_type is defined. By using MYSQL_BOTH (default), you'll get an array with both associative and number indices. Using MYSQL_ASSOC, you only get associative indices (as mysql_fetch_assoc() works), using MYSQL_NUM, you only get number indices (as mysql_fetch_row() works).

    In other words, since MYSQL_BOTH is the default, you get both back. You can specify either MYSQL_ASSOC or MYSQL_NUM instead to get an associative array or numeric array back. You could also use mysql_fetch_assoc() instead which will only return an associative array.

提交回复
热议问题