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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:54:10+00:00 2026-06-16T00:54:10+00:00

I would like to update information that is already in the database, but using

  • 0

I would like to update information that is already in the database, but using an array. I get ‘successfully update’ message white the data in the database is not updated.

the following is the function I use to do the insertion:

function update_knowledge_modules($update_data,$value)
{   
    $update = array();
    array_walk($update_data,'array_clean');

    foreach($update_data as $field=>$data)
    {
        $update[] = '.$field. = \''.$data.'\'';
    }



    $query = "UPDATE knowledge_modules SET".implode(', ',$update)."WHERE curr_code =$value";

    mysql_query($query)
    or die(mysql_error);

}

<?php

                    if(isset($_GET['success']) == true && empty($_GET['success'])==true)
                        {
                            echo 'Changed successfully';    
                        }
                    else
                        {
                            if(empty($_POST)== false && empty($errors)== true ) 
                                {
                                    $update_module = array(
                                    'KM_Number'=>$_POST['KM_Number'],
                                    'KM_Title'=>$_POST['KM_Title'],
                                    'NQF_Level'=>$_POST['NQF_Level'],
                                    'Credits'=>$_POST['Credits']


                                    );

                                    update_knowledge_modules($update_module,$_SESSION['Curr_Code']); 
                                    header('Location:edit_km_details.php?success');
                                    exit();
                                }
                        else if(empty($errors)== false)
                            {
                                echo output($errors);
                            }

              ?>

            <form action="edit_km_details.php" method="POST">
  • 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-16T00:54:11+00:00Added an answer on June 16, 2026 at 12:54 am

    Well, first of all, you are outputting the “changed successfully” message solely based on $_GET['success'] being truthy. It has nothing to do with whether you had success or failure in your update_knowledge_modules function call at all, which seems odd.

    Second of all, I don’t see anywhere where you are actually making a database connection.

    Third, your query is undoubtedly being formed improperly. Look at this:

    $update[] = '.$field. = \''.$data.'\'';
    

    you are going to get a literal $field and backslashes in your query string. Try this:

    $update[] = $field . " = '" . $data . "'";
    

    Also where you put your imploded array in the final query, you don’t have spaces after SET and before WHERE.

    Anytime you are having problems with a query, just var_dump it and run it on the database directly to see why it isn’t working and look at your errors, including mysql errors.

    Finally, you should not be using the mysql_* family of functions. They are deprecated.

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

Sidebar

Related Questions

I'm making an update to our database and would like to update rows that
I would like to update my current SB2 theme Sunburst so that the current
I would like to update some data with JSON when the user clicks on
Say I wanted to perform an update in a database that held information on
I have a form that allows a user to update their profile information, but
I would like to update (change the content) some part of the webpage without
I would like to update 3 rows of a single table, with different values
I would like to update an xml file from another xml file.I have used
I would like to update the Diagnostic configuration file for the azure roles whenever
I would like to update one of the variables in a vector layer class

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.