Database escape problem |
[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?
[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'); |
Welcome Guest, Not a member yet? Register Sign In |