CodeIgniter Forums

Full Version: Please help me
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

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

El Forum

Im programing a forum by codeigniter



El Forum

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

El Forum

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?


El Forum

'0' is not 0...

El Forum

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