Database escape problem - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Database escape problem (/showthread.php?tid=9913) |
Database escape problem - El Forum - 07-12-2008 [eluser]no_Ob[/eluser] Hi all I am just a beginner and i have just started using CI again Dealing with the databases I run into a problem. Code: $username=$_POST["username"]; If I run this code CI give me this error: Quote:An Error Was Encountered But if I comment out the escape commands everthing works fine. What am I doing wrong? Database escape problem - El Forum - 07-12-2008 [eluser]Derek Jones[/eluser] escape() already adds quotes for you intelligently based on the variable type. So you're ending up with double single quotes: Code: VALUES(’’dasd’’ Don't use quotes around your variables that you are escape()ing. Alternatively, use $this->db->escape_str() which just escapes the data and doesn't add quotes. User Guide Reference Or you can use Active Record's insert() method to handle it all for you: Code: $data['username'] = $this->input->post('username'); |