Prima cosa.

Codice PHP:
If ($result == false) echo "Query fallita\n<br/>"