From:             wilsonwg at gmail dot com
Operating system: Windows XP SP2
PHP version:      5.2.4
PHP Bug Type:     MySQLi related
Bug description:  mysqli would not return result values within "for" loop.

Description:
------------
I set up an array in the code and then use the for loop to query my
database. However, the mysqli functions would not return the result
values.

This is the table used for the query(columns separated a comma):

-------------
id, item_name
-------------
1, item_1
2, item_2
3, item_3
4, item_4
------------- 




Reproduce code:
---------------
$mysqli_connect =mysqli_connect("localhost", "root", "password", "myDB"); 
 

  $array_items = "item_1,item_2,item_3,item_4";
  $array_list = explode (",", $array_items);
  
  for ($i=0; $i<count($array_list); $i++){           

  $select_item = "SELECT * FROM compounds where item_name =
'".$array_list[$i]."'";
  
  echo "$select_item <p>";
  
  $search_item_query = mysqli_query($mysqli_connect, $select_item);
  
  $result = mysqli_fetch_array($search_item_query);
  
  $id = $result['item_id']; 
  echo "$id <p>";          
}

Expected result:
----------------
SELECT * FROM compounds where compound_name = 'item 1'

1

SELECT * FROM compounds where compound_name = 'item 2'

2

SELECT * FROM compounds where compound_name = 'item 3'

3

SELECT * FROM compounds where compound_name = 'item 4'

4

Actual result:
--------------
SELECT * FROM compounds where compound_name = 'item 1'

SELECT * FROM compounds where compound_name = 'item 2'

SELECT * FROM compounds where compound_name = 'item 3'

SELECT * FROM compounds where compound_name = 'item 4'


-- 
Edit bug report at http://bugs.php.net/?id=42961&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42961&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42961&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42961&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42961&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42961&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42961&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42961&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42961&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42961&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42961&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42961&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42961&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42961&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42961&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42961&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42961&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42961&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42961&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42961&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42961&r=mysqlcfg

Reply via email to