I am trying to create a temporary table from php but when doing the select it tells me that: mysqli_fetch_assoc () expects parameter 1 to be mysqli_result, boolean given in The code is as follows:
mysqli_query($db,"DROP TABLE IF EXISTS T");
$temp="CREATE TEMPORARY TABLE T AS
(SELECT @rownum := @rownum + 1 'posicion',
nombre,
dificultad as fallos,
palabra,
fecha,
id
FROM palabras p,(SELECT @rownum := 0) r
where nombre IS NOT NULL ORDER BY dificultad, fecha DESC )";
mysqli_query($db,$temp);
$usuarios=" SELECT * FROM T
WHERE posicion <= 3 OR id = (SELECT MAX(id) FROM T) ORDER BY posicion";
$res=mysqli_query($db,$usuarios);
$fila=mysqli_fetch_assoc($res);
I get the impression that the temporary table is created but before it can show it is destroyed, which may be failing? The user has all the privileges on the database Thanks