Welcome Guest, Not a member yet? Register   Sign In
Hidden Value Insert Problem
#11

[eluser]oliur[/eluser]
Steps to check:

1. Make sure your field type is a TIMESTAMP in MySQL table
2. You do not need to use a hidden field
3. You do not need to pass date from your view to controller - just pass it from your controller directly
4. In your controller use PHP date function:

$data['date'] = date('Y-m-d H:iConfused');

And then insert that into mysql

$this->db->insert('posts',$data);

5. Job done.


#12

[eluser]Zed[/eluser]
[quote author="oliur" date="1333107729"]Steps to check:

1. Make sure your field type is a TIMESTAMP in MySQL table
2. You do not need to use a hidden field
3. You do not need to pass date from your view to controller - just pass it from your controller directly
4. In your controller use PHP date function:

$data['date'] = date('Y-m-d H:iConfused');

And then insert that into mysql

$this->db->insert('posts',$data);

5. Job done.


[/quote]

Thanks. Its working now!
#13

[eluser]Zed[/eluser]
Thank you all very much. I am progressing gradually in my codeigniter experience all because of the help you guys are rendering. I guest my next stop at this juncture will be on how to retrieve data back from database. Glad to know i can count on you guys.

Thanks all
#14

[eluser]Zed[/eluser]
the problem was with my date format on mysql, i was using DATETIME, but when i changed to TIMESTAMP, voila! it did the magic. but why wont the DATETIME work?
#15

[eluser]oliur[/eluser]
[quote author="Zed" date="1333111538"]the problem was with my date format on mysql, i was using DATETIME, but when i changed to TIMESTAMP, voila! it did the magic. but why wont the DATETIME work?[/quote]

Hope this thread helps




Theme © iAndrew 2016 - Forum software by © MyBB