Edit report at http://bugs.php.net/bug.php?id=54008&edit=1
ID: 54008
Comment by: lkzwieder at hotmail dot com
Reported by: lucas dot tettamanti at gmail dot com
Summary: mysql_fetch_assoc() expects parameter 1 to be
resource
Status: Bogus
Type: Bug
Package: MySQL related
Operating System: Linux Mint 10 (Julia)
PHP Version: 5.3.5
Block user comment: N
Private report: N
New Comment:
p.tamaño ---> change the name of this field in database... I'm sure
that the query works fine in MySql, but PHP doesn't accept ñ in the key
of an array.
Thats the problem...
Previous Comments:
------------------------------------------------------------------------
[2011-02-13 18:02:52] [email protected]
You need to check the return value of mysql_query() for errors as it
won't magically emit one -> Bogus.
------------------------------------------------------------------------
[2011-02-13 17:17:59] lucas dot tettamanti at gmail dot com
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 this bug report at http://bugs.php.net/bug.php?id=54008&edit=1