bonaca bonaca - 1 year ago 106
PHP Question

mysql query wrong syntax

What is wrong with this syntax, please:

$stmt = $db->query('SELECT id, par, what, title, inde
FROM tmatria
where par = ' . $_SESSION["par"] . ';');


SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'where par = 0' at line 1

Answer Source

The ORDER clause should come after WHERE clause

$stmt = $db->query("SELECT id, par, what, title,  inde FROM tmatria where par = '$_SESSION[par]' ORDER BY inde ASC");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download