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

[eluser]saymes[/eluser]
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
#2

[eluser]saymes[/eluser]
Im programing a forum by codeigniter

Arabic
http://upload.traidnt.net/upfiles/kC181412.jpg

English
http://upload.traidnt.net/upfiles/uXx81369.jpg
#3

[eluser]saymes[/eluser]
I Will change the style later so Please help me With My problem
#4

[eluser]John_Betong[/eluser]
Please use CODE options to wrap your code.

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?

 
 
 
#5

[eluser]danmontgomery[/eluser]
'0' is not 0...
#6

[eluser]pickupman[/eluser]
[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