Welcome Guest, Not a member yet? Register   Sign In
Please help me

When i enter the data to the base With
the following Code :

$data = array(
'title' => $title ,
'from_main_section' => '0'
$this->db->insert('section', $data);

its Giving me an error :

A Database Error Occurred

Error Number: 1048

Column 'from_main_section' cannot be null

INSERT INTO `myforum_section` (`title`, `from_main_section`) VALUES ('test forum', NULL)

I want value to be 0 not NULL

Please help me and Thank you

Im programing a forum by codeigniter



I Will change the style later so Please help me With My problem

Please use CODE options to wrap your code.

$data = array
         ‘title’ => $title ,
         ‘from_main_section’ => ‘0’
$this->db->insert(‘section’, $data);

// added this line
echo $this->db->last_query();

I modified your code to suit my database, tables and fields and the insertion worked fine. I also had to change the backticks to single quoation marks.

Have you:
1. loaded the database correctly?
2. Do you have other SQL statements that are working correctly?
3. Do either title or from_main_section have unique indexes
4. Have you manually tried using the SQL statement in PhpMyAdmin?


'0' is not 0...

[quote author="noctrum" date="1283276778"]'0' is not 0...[/quote]
Exactly, with quotes that becomes a string and not bool/null.

Theme © iAndrew 2016 - Forum software by © MyBB