Select Query Error |
Hi everyone, i have a problem with a select query,
Code: $where = "SELECT FORMAT(SUM(payed), 2) AS payedAmount FROM client_credit WHERE creditStatus = 2 AND idperson = '" But i get a boolean result, $query = false, and when i execute the same query in mysql console i get the right result, but here i get boolean. Thank you. ![]()
Did you add an echo $where; to get the generated SQL or did you just guess what it actually generated and run it in MySQL console?
Also, your code are vulnerable to SQL Injection, you should fix that ASAP! https://www.codeigniter.com/user_guide/d...y-bindings https://en.wikipedia.org/wiki/SQL_injection
Insert these 2 lines just for testing purposes after $query = $this->db->query($where);
PHP Code: echo $this->db->last_query(); This will echo the query like it's being sent to MySQL. Check if this is what you expected.
are you sure your idperson is a string in your database??
change: PHP Code: $where = "SELECT FORMAT(SUM(payed), 2) AS payedAmount FROM client_credit WHERE creditStatus = 2 AND idperson = '" PHP Code: $where = "SELECT FORMAT(SUM(payed), 2) AS payedAmount FROM client_credit WHERE creditStatus = 2 AND idperson = " |
Welcome Guest, Not a member yet? Register Sign In |