0
SELECT  p.autor, p.tresc, p.data, u.id
FROM   pages_com p
       LEFT OUTER JOIN users u on p.autor = u.username
WHERE p.wpis = ?
ORDER BY p.id DESC

My error is:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? ORDER BY p.id DESC LIMIT 0, 30' at line 4

My code:

$query = "SELECT  p.autor, p.tresc, p.data, u.id
FROM   pages_com p
       LEFT OUTER JOIN users u on p.autor = u.username
WHERE p.wpis = ?
ORDER BY p.id DESC";
                $statement = $databaseConnection->prepare($query);
                $statement->bind_param('s', $id);

Error in fucntion bind_param:

Fatal error: Call to a member function bind_param() on a non-object in /home/p503373/public_html/v2/page.php on line 81

jarlh
  • 42,561
  • 8
  • 45
  • 63
LuKiO
  • 1
  • 1
    `$statement = $databaseConnection->prepare($query);` < that failed and you're not trapping errors, check `$databaseConnection` – CD001 May 31 '17 at 15:01
  • @ccKep MySQL has of course left outer join – Jens May 31 '17 at 15:04
  • 1
    It looks like `LEFT OUTER JOIN` is supported by MySQL: https://dev.mysql.com/doc/refman/5.7/en/join.html – Tim Biegeleisen May 31 '17 at 15:04
  • I know, I was a bit confused - deleted the comment literally 2 secs after posting ;-) – ccKep May 31 '17 at 15:05
  • What's the problem ? Can you provide a solution to this problem? In another file such application worked and not here. – LuKiO May 31 '17 at 15:08

0 Answers0