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

  • Home
  • SEARCH
  • 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 574369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:49:24+00:00 2026-05-13T13:49:24+00:00

I dont know why this particular bit of code is simply not updating despite

  • 0

I dont know why this particular bit of code is simply not updating despite using this style of coding elsewhere succesfully.No exception is being thrown.

CREATE TABLE `accounts` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `accounts_username` varchar(60) DEFAULT NULL,
  `accounts_fullname` varchar(600) DEFAULT NULL,
  `accounts_email` varchar(600) DEFAULT NULL,
  `accounts_password` varchar(600) DEFAULT NULL,
  `accounts_status` varchar(600) DEFAULT NULL,
  `accounts_roles` varchar(600) DEFAULT NULL,
  `accounts_comments` text,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1

In my form I have the code

public function __construct($options = null)
    {
        parent::__construct($options);

        $optionsrole = array(
                'guest' => 'guest',
                'user' => 'user',
                'writer' => 'writer',
                'admin' => 'admin'              
                );

        $optionsstatus = array(
                'active' => 'active',
                'pending' => 'pending'              
                );

        $this->setName('account');
        $id = new Zend_Form_Element_Hidden('id');
        $username = new Zend_Form_Element_Text('accounts_username');
        $username->setLabel('Username')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty');
        $fullname = new Zend_Form_Element_Text('accounts_fullname');
        $fullname->setLabel('Fullname')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty');
        $email = new Zend_Form_Element_Text('accounts_email');
        $email->setLabel('Email')
                ->setRequired(true)
                ->addFilter('StripTags')
                ->addFilter('StringTrim')
                ->addValidator('NotEmpty')
                ->addValidator(new Zend_Validate_EmailAddress());
        $password = new Zend_Form_Element_Password('accounts_password');
        $password->setLabel('Password')
                    ->setRequired(true)
                    ->addFilter('StripTags')
                    ->addFilter('StringTrim')
                    ->addValidator('NotEmpty');
        $status = new Zend_Form_Element_Select('accounts_status');
        $status->setLabel('Status')
                ->setRequired(true)
                //->addMultiOptions(array('Active','Pending'));
                ->addMultiOptions($optionsstatus);

        $role = new Zend_Form_Element_Select('accounts_roles');
        $role->setLabel('Role')
                ->setRequired(true)
                //->addMultiOptions(array('guest','user','writer','admin'));
                ->addMultiOptions($optionsrole);

        $comments = new Zend_Form_Element_Textarea('accounts_comments');
        $comments->setLabel('Comments')
                //->setAttrib('size',200)
                ->setAttrib('rows',20)
                ->setAttrib('cols',50);             

        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id', 'submitbutton');
        $this->addElements(array($id, $username, $fullname,$email,
        $password,$status,$role,$comments,$submit));
    } 

In my accounts controller

public function editAction()
    {
        $this->view->title = "Edit User Account";
        $this->view->headTitle($this->view->title, 'PREPEND');
        $form = new Form_Account();
        $form->submit->setLabel('Save');
        $accounts = new Model_DbTable_Account();
        $this->view->form = $form;
        if ($this->getRequest()->isPost()) {
            $formData = $this->getRequest()->getPost();
            if ($form->isValid($formData)) {
                /*
                if($accounts->checkUnique($formData['accounts_username'])){
                    $this->view->errorMessage = "Username already taken. Please choose another one.";
                    return; 
                }
                */
                $id = (int)$form->getValue('id');
                $username = $form->getValue('accounts_username');
                $fullname = $form->getValue('accounts_fullname');
                $email = $form->getValue('accounts_email');
                $password = $form->getValue('accounts_password');
                $status = $form->getValue('accounts_status');
                $roles = $form->getValue('accounts_roles');
                $comments = $form->getValue('accounts_comments');
                //$accounts = new Model_DbTable_Account();
                $accounts->updateaccount($username, $fullname,$email,
                $password,$status,$roles,$comments);
                $this->_redirect('/account');
            } else {
                $form->populate($formData);
            }
        } else {
            $id = $this->_getParam('id', 0);
            if ($id > 0) {
                $account = new Model_DbTable_Account();
                $form->populate($account->getaccount($id));
            }
        }
    }

In my model

public function updateaccount($id,$username, $fullname, $email,
                $password,$status,$roles,$comments)
    {
        $data = array(
                'accounts_username' => $username,
                'accounts_fullname' => $fullname,
                'accounts_email' => $email,
                'accounts_password' => md5($password),              
                'accounts_status' => $status,
                'accounts_roles' => $roles,             
                'accounts_comments' => $comments,
        );
        $this->update($data, 'id = '. (int)$id);
    }

Am i missing something?

  • 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-13T13:49:25+00:00Added an answer on May 13, 2026 at 1:49 pm

    I did find the problem.I was not passing the $id creteria and therefore no record was been updated.

    $accounts->updateaccount($username, $fullname,$email,
                            $password,$status,$roles,$comments);
    

    It should have instead read

    $accounts->updateaccount($id,$username, $fullname,$email,
                            $password,$status,$roles,$comments);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't know if this is possible or not, or if my limited knowledge
Seems so basic, I can't believe I don't know this! I just need a
I don't know if this has been discussed. Let's say you are in a
I don't know why this bothers me so much, but when I create websites,
I don't know why this method returns a blank string: - (NSString *)installedGitLocation {
I don't know if this is the right way to phrase the question or
I don't know if this is too specific a question, if that is possible,
problem euler #5 i found the solution but i don't know why this first
I don't know if anyone has seen this issue before but I'm just stumped.
Whether this is possible I don't know, but it would mighty useful! I have

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.