Bug #72211 [Opn->Fbk]: Associative array returns not = Numeric array

From: Date: Thu, 12 May 2016 22:15:49 +0000
Subject: Bug #72211 [Opn->Fbk]: Associative array returns not = Numeric array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201052@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72211&edit=1 ID: 72211 Updated by: requinix@php.net Reported by: 4OtherBusiness at comcast dot net Summary: Associative array returns not = Numeric array -Status: Open +Status: Feedback Type: Bug Package: MySQLi related Operating System: Windows 7 Enterprise PHP Version: 5.6Git-2016-05-12 (snap) Block user comment: N Private report: N New Comment: Are there 149 or 150 elements in the $row array? Does your query return more than one field named "modem_config_id"? Previous Comments: ------------------------------------------------------------------------ [2016-05-12 22:07:28] 4OtherBusiness at comcast dot net Description: ------------ Inside my PHP do_mysql_multi() funct that does querying, I kept getting nonsense until I put this first echo just below the while () shown here. (Using newer mysqli not mysql functions.) Basically the associative value is wrong, the numeric indexed value is correct for first element of first (only) row. Putting: echo "<pre>"; print_r($row) ; Shows the nonsense when placed after the test for result = mysqli_store_result($link) 75 columns expected c/o SELECT tbl1.*, tbl2.*, tbl3.*, tbl4.*, tbl5.* .... First few fields (of the 1 return row) shown here. Notice first element. Should be = 101, (= where clause value) Array ( [0] => 101 [modem_config_id] => 1 [1] => 1 [modem_activity_id] => 1 [2] => 1 [customer_id] => 1 [3] => 1 [aircraft_id] => 1 [4] => 1 [intl_rate_plan_id] => 1 [5] => 1 [dom_rate_plan_id] => 1 [6] => U064672 [serial_number] => U064672 ... All the rest are good Test script: --------------- if (mysqli_multi_query($link,$query )) { do { if ($result = mysqli_store_result($link)) { $row_nbr=0 ; while ($row = mysqli_fetch_array($result, MYSQLI_BOTH)) { $row_nbr++ ; for ($field_nbr=1;$field_nbr<=$fields_returned;$field_nbr++) { $values[$row_nbr][$field_names[$field_nbr]] =$row[$field_nbr-1] ; } } mysqli_free_result($result) ; } // EO if ($result = mysqli_store_result($link)) } while (mysqli_more_results($link) && mysqli_next_result($link)) ; } // EO if (mysqli_multi_query($link,$query )) else { // This will be true if the 1st query failed if ($query_nbr == 0) { $result_vector1['Error'] = "MySQL Error #: ".mysqli_errno($link).": ".mysqli_error($link) ; $result_vector2['Error'] = "MySQL Error in first query." ; } } // EO MySQL Expected result: ---------------- I expect [0] value to equal ['modem_config_id'] value. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=72211&edit=1

« previous php.bugs (#201052) next »