Ok I'm running a query and CodeIgniter is giving me this error:
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 4
SELECT username FROM friend_request JOIN user ON user_id = friend WHERE (friend = '8' AND sender =
I do realize, it's not catching the sender, HOWEVER $this->session->userdata('user_id') echos to be 4 (which is my user_id)... So how come it's not showing up as anything?
$this->db->query('SELECT username
FROM friend_request
JOIN user ON user_id = friend
WHERE (friend = ? AND sender = ?)
OR (friend = ? AND sender = ?)',
$user->row()->user_id,
$this->session->userdata('user_id'),
$this->session->userdata('user_id'),
$user->row()->user_id);
if($this->db->num_rows() > 0) {
$this->errors->set_error('You either have a pending request from '.ucfirst($this->db->row()->username).'
or you have already requested their friendship!');
return false;
}
I tried putting everything on one line because I didn't know if the enters would break anything, but it still didn't fix any of it.