Question

I'm using Codeigniter with Grocery Crud, to connect with a database in MySQL and PhpMyAdmin.

I installed everything as the tutorial said, but errors can always be there.

My problem is: I have a simple table (3 fields, one for name, another one for last name and another one for date of birth), using varchar (255) for the first two, and DATE for the date of birth. When I add a new record, or update an existing one, it says it successfully did the job, but it actually didn't. And ONLY with the DATE field. I can perfectly add and update the other 2 columns.

Any ideas?

EDIT: I added the code as asked for. This is the Controller that gets the patients:

<?php if (!defined('BASEPATH'))
    exit('No direct script access allowed');
class GetPatients extends CI_Controller
{

    function __construct()
    {
        parent::__construct();

        $this->load->database();
        $this->load->helper('url');

        $this->load->library('grocery_CRUD');
    }

    public function index()
    {
        echo "<h1>Welcome to the world of Codeigniter</h1>"; //Just an example to ensure that we get into the function
        die();
    }

    public function dbpatients()
    {
        $this->grocery_crud->set_table('patient');
        $output = $this->grocery_crud->render();

        $this->_example_output($output);
    }

    function _example_output($output = null)
    {
        $this->load->view('patients_view',$output);
    }

}
Was it helpful?

Solution

mysql date col only supports numbers or string as assignment values. you can convert your date format

$datestring = "%Y%m%d";
    $time = time();
    $date = mdate($datestring, $time);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top