Welcome Guest, Not a member yet? Register   Sign In
how to check for sql syntax error
#1

(This post was last modified: 12-06-2016, 08:05 PM by cupboy1.)

This is the code

      $q = $this->db->query($sql);
      if ($q === FALSE)
        //throw new Exception($this->db->error);  
        throw new Exception('stupid error'); 


It does not work. All that happen is the error is logged by codeignitor and the script is dead at that point. What am I doing wrong?

I may have posted a similar question earlier but I cannot locate it.

UPDATE: I have fixed the problem by modifying some apparently bad code in DB_driver.php that was causing the script to blow up when it attempted this: $this->display_error(array('Error Number: '.$error['code'], $error['message'], $sql))
I commented that line out so that query() will return FALSE if the SQL fails. Works fine for me now anyway...
Reply
#2

Maybe this will help:
http://stackoverflow.com/questions/32345...ysql-error
Reply




Theme © iAndrew 2016 - Forum software by © MyBB