Welcome Guest, Not a member yet? Register   Sign In
Internal Server Error when using $this->db->insert
#1

(This post was last modified: 05-22-2015, 01:27 AM by Radiart.)

Hi guys I have problem with updating my database.

I'm using Codeigniter 3.0

When I copy sample code from doc everything works:

PHP Code:
$data = array(
                    
'title' => 'My title',
                    
'name' => 'My Name',
                    
'date' => 'My date'
            
);

            
$sql $this->db->insert('mytable'$data);
            echo 
$sql

But when I'm trying send my array:


PHP Code:
Array(
    [
id_store] => 78
    
[id_campaigns] => 42
    
[cause] => 1
    
[name] => sd
    
[weight] => 45345
    
[contact] => sdfsd
    
[phone] => fsdf
    
[contacted] => 1
    
[added] => 2015-05-21 18:24:03


I always get blank page and Invalid HTTP status code 500

The page is in AngularJS, I geting data from form in JSON format

I my controller I have:

PHP Code:
        // JSON
        
$post file_get_contents('php://input');
        
$_POST json_decode$post true ); 

What I'm doing wrong?
Reply
#2

Turn up error reporting (to 4) and check the log file it generates in /application/logs.

It could be due to your query failing or something in your code that you aren't showing. Are you using form validation? If so, wiping out POST with a json string probably won't work.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB