Error when inserting from $_POST with Active Record |
[eluser]Buso[/eluser]
$this->db->insert('comments',$_POST); I get this: >> Unknown column 'submit' in 'field list' >> INSERT INTO `comments` (`user_name`, `email`, `body`, `submit`, `article_id`, `date`) VALUES ('aa', 'ff', 'aaa', 'Post!', '2', 1255932082) Its trying to insert the submit field =S, and even worse, its trying to insert article_id as a string.. What can I do??
[eluser]rogierb[/eluser]
Hey there, 1: RTFM, there is a thing called the user_guide 2: NEVER everr use $_POST to insert, always clean up your vars. 3: remove the submit field/button from your form(rename it, but much much better would be to do point 2). 4: Article_id is not inserted as a string just because there a quotes around it. It will still be processed as an integer.
[eluser]Buso[/eluser]
[quote author="rogierb" date="1255952395"]Hey there, 1: RTFM, there is a thing called the user_guide [/quote] I've read it, thanks Quote:2: NEVER everr use $_POST to insert, always clean up your vars.You are right, i just wanted to try this active record thing. Quote:3: remove the submit field/button from your form(rename it, but much much better would be to do point 2).how? rename it to what? Quote:4: Article_id is not inserted as a string just because there a quotes around it. It will still be processed as an integer.ok
[eluser]rogierb[/eluser]
3: hmm error on my side, I guess you are using form_button(). This generates a button with a 'name'. Just use a custom html button without the name element. But like I said, don't use $_POST, Then you don't have problem.
[eluser]daparky[/eluser]
[quote author="rogierb" date="1255952395"]Hey there, 1: RTFM, there is a thing called the user_guide 2: NEVER everr use $_POST to insert, always clean up your vars. 3: remove the submit field/button from your form(rename it, but much much better would be to do point 2). 4: Article_id is not inserted as a string just because there a quotes around it. It will still be processed as an integer.[/quote] How would you go about point 2?
[eluser]pistolPete[/eluser]
[quote author="daparky" date="1255991267"]How would you go about point 2?[/quote] http://ellislab.com/codeigniter/user-gui...input.html |
Welcome Guest, Not a member yet? Register Sign In |