Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8316107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:17:04+00:00 2026-06-08T21:17:04+00:00

I’m new to CodeIgniter. I’m using Phil Sturgeon’s RestServer and RestClient. I’ve been trying

  • 0

I’m new to CodeIgniter. I’m using Phil Sturgeon’s RestServer and RestClient. I’ve been trying to make a POST request in my CodeIgniter RestClient controller to update data in my CodeIgniter RestServer, but it never updates data in my database. I think my POST request is not right.

Here is my RestClient POST request in controller:

$result = $this->rest->post('newscontroller/news/format/json', 
          array('news_id' => $news_id,
                'news_title' => $news_title,
                'news_category' => $news_category ),
                'json'); 

if(isset($result->status) && $result->status == 'success')  
{  
        $data['message'] ='News has been updated.';  
        $this->load->view('otherpageview',$data);
}     
else  
{  
        $data['message'] ='Something has gone wrong';  
        $this->load->view('otherpageview',$data);
} 

It seems that $result doesn’t get any value, because I did echo the $result->status and it has nothing to display. And I’ve also have this in this controller’s constructor :

// Load the rest client spark
$this->load->spark('restclient/2.1.0');

// Load the library
$this->load->library('rest');

// Run some setup
$this->rest->initialize(array('server' => 'http://api.therestserver.com/index.php/'));

And in the RestServer’s controller, which is newscontroller, has this method :

function news_post()
{
    $news=array(
        'news_id' => $this->post('news_id'),
        'news_title' => $this->post('news_title'),
        'news_category' => $this->post('news_category') );

    $result = $this->News_model->UpdateNews($news);  

    if($result === FALSE)  
    {  
        $this->response(array('status' => 'failed'));  
    }  
    else  
    {  
        $this->response(array('status' => 'success'));  
    }
}

With the News_model :

public function UpdateNews($news)
{
    $this->db->where('news_id',$news->news_id);
    $this->db->update('news',$news);        
}

I just don’t know where I’m doing wrong, because I still don’t understand how the POST request and method work. I’ve read through the tutorial in Nettuts and search about this, but still.. maybe because of my bad English reading-writing. I hope someone can help me out, any help would be appreciated. Thanks a TON! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:17:07+00:00Added an answer on June 8, 2026 at 9:17 pm

    Finally SOLVED this problem!
    It was my POST request in the RESTClient controller that is wrong. After doing some searching and lots of trying / changing the codes, this code works for me for POST request in my RESTClient controller :

    $news_id = 12; //this is the id of the news that you want to edit
    
    $method = 'post';
    $params = array('news_id' => $news_id, 
    'news_title' => $this->input->post('news_title'), 
    'news_category' => $this->input->post('news_category') );
    $uri = 'newscontroller/news';
    
    $this->rest->format('application/json');
    
    $result = $this->rest->{$method}($uri, $params);
    
    if(isset($result->status) && $result->status == 'success')  
    {  
        $data['message'] ='News has been updated.';  
        $this->load->view('otherpageview',$data);
    }     
    else  
    {  
        $data['message'] ='Something has gone wrong';  
        $this->load->view('otherpageview',$data);
    } 
    

    With a lot of help from this reference

    I post this if anybody needs an example of the right POST request in RESTClient and RESTServer, because I find it hard to look for an example for POST request in RESTClient-Server*** by Phil Sturgeon.

    I’m using :

    • RESTServer (philsturgeon) v.2.6.0
    • RESTClient (philsturgeon) v.2.1.0
    • cURL (philsturgeon) v.1.2.1
    • CodeIgniter v.2.0.3
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm trying to create an if statement in PHP that prevents a single post
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.