CodeIgniter Forums
Please help me - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Please help me (/showthread.php?tid=33510)



Please help me - El Forum - 08-29-2010

[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


Please help me - El Forum - 08-29-2010

[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


Please help me - El Forum - 08-29-2010

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


Please help me - El Forum - 08-31-2010

[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?

 
 
 


Please help me - El Forum - 08-31-2010

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


Please help me - El Forum - 08-31-2010

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