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 6788083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:26:33+00:00 2026-05-26T17:26:33+00:00

I use the latest code igniter (2.0.3) and php-active 0.0.1. All are working fine

  • 0

I use the latest code igniter (2.0.3) and php-active 0.0.1.

All are working fine except save();

Code:

if($_POST)
{               
  $entry= Customers::find_by_routeid('4');
  $entry->routeid=5;
  $entry->save();              
}

Here’s my problem: for some reason that I cannot understand the above code does not work, but if I take the code out of if ($_POST), it works fine.

What I am doing wrong?


EDIT:

Thanks Damien Pirsy $this->input->post() does the trick, but when I uncomment the comments in the code the problems returns.

The code now is:

if($this->input->post())
{
  $id = $this->input->post('id');
  $oldRoute = $this->input->post('oldRoute');
  $newRoute = $this->input->post('newRoute');

  $entry=  Customers::find_by_routeid($this->input->post('oldRoute'));
  $entry->routeid=$this->input->post('newRoute');
  $entry->save();

  /*
  if($oldRoute<$newRoute)
  {
    for ($i=$newRoute; $i>$oldRoute; $i--)
    {
      $element = Customers::find_by_routeid($i);
      echo $element->routeid -= 1;
      $element->save();
    }
  }
  */
}

The elements new IDs ($element->routeid -= 1;) are echoing right, but I have the same problem as in the beginning and neither of two saves work.

  • 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-05-26T17:26:33+00:00Added an answer on May 26, 2026 at 5:26 pm

    You didn’t provide much details or debug info, so I’ll just guess: try using the CI’s native post handler instead. You should have var_dump()ed the $_POST array, see if isset() or not, also, since you’re using it as a condition

    if($this->input->post())
    {
      //...
    }
    

    UPDATE:

    Since we’re talking about Post variables, don’t assume they’re exactly as you want them. Keep in mind that $this->input->post('field') returns FALSE when the index is not present; that might well brake your if condition.
    Assuming you need numbers to do this, you can do a check like

    if($this->input->post('newRoute') AND is_numeric($this->input->post('newRoute'))
    {
      $newRoute = $this->input->post('newRoute');
    }
    else
    {
      // give it a default value, or raise an error, for example. If you need this
      // variables, and need them to be numbers, you cannot go on in case these 
      // conditions are not met, right?
    }
    

    And the same for $oldRoute.
    And yeah, OK, maybe you can write a cleaner code than mine, but you get the picture 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My base url function is not working in the latest version of code igniter.
We have several common libs. Ideally we want them all to use the latest
Background We use a central repository model to coordinate code submissions between all the
I am trying to use the TFS API to retrieve the latest code from
I am trying to use the latest SDK for PHP (v. 1.5.0). I am
I have been working on some code, which I use git to manage. Earlier,
This following code snippet works fine using jQuery1.2.3, but it doesn’t work with latest
I use the latest TChromium Delphi wrapper of Chromium Embedded Framework from (http://code.google.com/p/delphichromiumembedded/). The
I want to use the latest gwt-incubator drop - gwt-incubator-july-14-2009.jar - in a Maven
I have been trying to use the latest NAnt (0.86 Beta 1) for a

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.