![]() |
[solved!] A Database Error Occurred - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: [solved!] A Database Error Occurred (/showthread.php?tid=26347) |
[solved!] A Database Error Occurred - El Forum - 01-11-2010 [eluser]maria clara[/eluser] hi, i encounter this error when im trying to add a new data in my jqgrid. the data was shown but it shows this in my console. Code: Error Number: 1064</p><p>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 'return) as `return` hope someone can help me.. thanks in advance, maria [solved!] A Database Error Occurred - El Forum - 01-11-2010 [eluser]whobutsb[/eluser] Possibly remove the single quotes around 'return' at the end, in your model. Can you post your model function? [solved!] A Database Error Occurred - El Forum - 01-11-2010 [eluser]maria clara[/eluser] here's the function in my MODEL: Code: function updateCustomerBalance($data) and also im having this error Code: <p>Message: Undefined index: client_id</p> and this points to the database error i encountered [solved!] A Database Error Occurred - El Forum - 01-11-2010 [eluser]WebsiteDuck[/eluser] You need to put backticks around the first return like so: Code: $this->db->select('SUM(gross) as sales, SUM(paid) as payment, SUM(credit) as credit, SUM(debit) as debit, SUM(`return`) as `return`'); Also $data['client_id'] doesn't exist, per your error [solved!] A Database Error Occurred - El Forum - 01-11-2010 [eluser]maria clara[/eluser] i have put this: Code: $this->db->select("SUM(gross) as sales, SUM(paid) as payment, SUM(credit) as credit, SUM(debit) as debit, SUM(`return`) as `return`"); and it doesn't show the database error log. but i have this in my console message Code: <h4>A PHP Error was encountered</h4> [solved!] A Database Error Occurred - El Forum - 01-11-2010 [eluser]John_Betong[/eluser] Try this and see what is in your $data array() Code: function updateCustomerBalance($data) [solved!] A Database Error Occurred - El Forum - 01-11-2010 [eluser]Dyllon[/eluser] [quote author="maria clara" date="1263288589"]i have put this: Code: $this->db->select("SUM(gross) as sales, SUM(paid) as payment, SUM(credit) as credit, SUM(debit) as debit, SUM(`return`) as `return`"); and it doesn't show the database error log. but i have this in my console message Code: <h4>A PHP Error was encountered</h4> The error is really self explanatory, your $data array does not contain a key 'client_id' but you're referencing it. Check your controller, why are you expecting a 'client_id' and why isn't one being supplied? and further more why not add some error checking if there's a possibility the 'client_id' could be missing? [solved!] A Database Error Occurred - El Forum - 01-11-2010 [eluser]maria clara[/eluser] [quote author="John_Betong" date="1263289532"] Try this and see what is in your $data array() Code: function updateCustomerBalance($data) [/quote] i have tried it and it shows this.. Code: </div><pre>Array [solved!] A Database Error Occurred - El Forum - 01-11-2010 [eluser]WebsiteDuck[/eluser] [quote author="maria clara" date="1263290103"] Code: </div><pre>Array There is no client_id in your $data array [solved!] A Database Error Occurred - El Forum - 01-11-2010 [eluser]maria clara[/eluser] i commented for a while the $data['client_id'] Code: $this->db->where('client_id'/*, $data['client_id']*/); and now it doesn't show the error. i still figuring out where can that be placed?? |