From:
Operating system: Linux Mint 10 (Julia)
PHP version: 5.3.5
Package: MySQL related
Bug Type: Bug
Bug description:mysql_fetch_assoc() expects parameter 1 to be resource
Description:
------------
If I change the current 'SELECT' to 'SELECT * FROM...' the script works
fine. Otherwise PHP shows me the follow warning:
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean
given in /opt/lampp/htdocs/distri/functions.php on line 158
Test script:
---------------
function get_productos($link,$params = null){
$query = "SELECT p.id, p.codigo, p.nombre, f.nombre as familia,
pro.nombre as provedor, p.precio, p.tamaño, p.medida
FROM productos p
INNER JOIN familias f ON p.familia = f.id
INNER JOIN provedores pro ON p.provedor = pro.id";
$result = mysql_query($query, $link);
$i = 0;$productos = array();
while($data = mysql_fetch_assoc($result)){
foreach($data as $key => $valor){
$productos[$i][$key] = $valor;
}
$i++;
}
mysql_close($link);
return $productos;
}
Expected result:
----------------
I expect fill the array $prod with data.
Actual result:
--------------
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean
given in /opt/lampp/htdocs/distri/functions.php on line 158
--
Edit bug report at http://bugs.php.net/bug.php?id=54008&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=54008&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=54008&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=54008&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=54008&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=54008&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=54008&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=54008&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=54008&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=54008&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=54008&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=54008&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=54008&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=54008&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=54008&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54008&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54008&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=54008&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=54008&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=54008&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=54008&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=54008&r=mysqlcfg