CodeIgniter Forums
SQL error? Why? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: SQL error? Why? (/showthread.php?tid=1075)



SQL error? Why? - behnampmdg3 - 02-09-2015

Why do I get this error? Looks like it's not escaping.
Quote:Error Number: 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 '?' at line 2

SELECT item FROM breakup_program_menu INNER JOIN breakup_members ON breakup_program_menu.program = breakup_members.program AND breakup_members.id = ?

Filename: models/Breakup_model.php

Line Number: 19
PHP Code:
public function program_items()
 {
 
$sql $this->db->query("
 SELECT item FROM breakup_program_menu INNER JOIN breakup_members 
 ON breakup_program_menu.program = breakup_members.program AND breakup_members.id = ? "
);
 
$this->db->query($sql, array(5)); 
 return 
$query->result();
 } 



RE: SQL error? Why? - behnampmdg3 - 02-09-2015

Anyone?


RE: SQL error? Why? - Avenirer - 02-09-2015

SELECT item FROM breakup_program_menu INNER JOIN breakup_members ON breakup_program_menu.program = breakup_members.program WHERE breakup_members.id = ?


RE: SQL error? Why? - Rufnex - 02-10-2015

write
... where breakup_members.id = ?


RE: SQL error? Why? - Narf - 02-10-2015

Just look at what you're calling ... you're not passing any parameters for that query's execution.