Why isn't PHP running a complex query?
I have a really weird problem.
This is part of the .php page:
$query="SELECT idlezione, nomemateria, oinizio, ofine FROM materia, lezione, ora, giorno WHERE materia.idmateria=lezione.idmateria AND ora.idora=lezione.idora AND giorno.idgiorno=lezione.giorno AND nomegiorno=\"$nomeg\" AND iddocente=\"$docente\" AND idclasse=\"$classe\" ORDER BY oinizio;";
echo $query;
$res=mysql_query($query,$dbconn);
echo mysql_num_rows($res);
Now when I copy the result echo $query;
into phpmyadmin it returns 2 lines to me, but it echo mysql_num_rows($res);
returns "0" in my .php .
If I use a simple query like SELECT * FROM materia;
it returns many rows.
UPDATE: Everything was on altervista.org, now I tried to move my db to local and run a query (using XAMPP) and everything works fine. Why?
+3
source to share
1 answer
I suggest using PDO and prepared statements.
Here's http://docs.php.net/pdo.prepared-statements an introduction to pdo and prepared statements (including related parameters).
-1
source to share