Hidden Value Insert Problem |
[eluser]Zed[/eluser]
hi, i want to insert current date into my db and the value comes from a hidden field in a form. i declared the date variable in my view file, all i got was 00:00:00 in the db, then i altered it and declared it in my controller file, but still didn't work this is what i did: view Code: $date = $date = date('Y-m-d H:i:s', now()); controller Code: $form_data = array(
[eluser]Matalina[/eluser]
Your view code is wrong. Remove the single quotes from $date; Code: $date = date('Y-m-d H:i:s', now());
[eluser]Zed[/eluser]
[quote author="Matalina" date="1333036557"]Your view code is wrong. Remove the single quotes from $date; Code: $date = date('Y-m-d H:i:s', now()); thanks, but it still not inserting
[eluser]Matalina[/eluser]
You don't need now() and I think that's the wrong function as well. If you want the current time you need to to time(); Now is only mysql function. but just leaving it empty will make it the currrent time. Read the php docs.
[eluser]Zed[/eluser]
[quote author="Matalina" date="1333050693"]You don't need now() and I think that's the wrong function as well. If you want the current time you need to to time(); Now is only mysql function. but just leaving it empty will make it the currrent time. Read the php docs.[/quote] thanks a great deal. I have removed the now, but its still the same. I feel the problem should be from the controller. I don't know if the controller is getting the date variable. I am going bald trying to figure this out. I've tried various approach all to no avail.
[eluser]Zed[/eluser]
I discovered that the date hidden field in the view file is not passing to the controller. I used a name other than date to insert the value into my database but with hidden field, i found that the value is not entering. What could be the cause?
[eluser]InsiteFX[/eluser]
WRONG! Now() is not only MySQL! Read the CodeIgniter Doc's! CodeIgniter has it's own now() function in the date_helper! CodeIgniter Users Guide -Date Helper
[eluser]Zed[/eluser]
[quote author="InsiteFX" date="1333057612"]WRONG! Now() is not only MySQL! Read the CodeIgniter Doc's! CodeIgniter has it's own now() function in the date_helper! CodeIgniter Users Guide -Date Helper [/quote] yeah. have seen it. but the problem on ground is that my form is not passing a variable. its a hidden field with date as a value/name but I keep getting 000 on my db. tried several methods but to no avail, then I decided to use a name instead of date and it still was not entering my db so I came to conclusion that my form is not passing the hidden field variable to my controller. that brings me to why is it not passing? thanks
[eluser]boltsabre[/eluser]
Bug hunting time... In your controller, try var_dump($_POST) and see what you're getting from your form (or var_dump($this->input->post()); But I'm at a complete loss as to why you want to pass the current date from your view, to your controller, then to your model - why not just set the date in your model SQL statement???
[eluser]InsiteFX[/eluser]
And what is your database field type set to? This is how I insert dates and times into my database field datetime Code: // -------------------------------------------------------------------- |
Welcome Guest, Not a member yet? Register Sign In |