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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:38:00+00:00 2026-06-17T13:38:00+00:00

I have a script that updates MySQL tables with the values from an HTML

  • 0

I have a script that updates MySQL tables with the values from an HTML and processed by PHP.
When I click on the edit link which is on the table it redirects me to the edit page, where it shows the records fetched from the MySQL database – but it does not update the record.

Here is my link code:

echo "<td><a href=\"cityproc.php?accode=$row[accode]\"><img src='images/edit.png'></a></td>";

Here is my edit page code:

<?php
session_start();
if (!isset($_SESSION["username"])) {
    header("Location: unauthorize_access.php");
}
mysql_connect("localhost", "root", '')or die(mysql_error());
mysql_select_db("webapp") or die(mysql_error());

$accode = mysql_real_escape_string($_REQUEST['accode']); // is used for both $_GET/$_POST variables

if(isset($_POST['submit']))
{

          $city = mysql_real_escape_string($_POST['city']);
          $result = mysql_query("UPDATE `city` SET `name`='$city' WHERE accode='$accode'") or die(mysql_error());

          echo "<b>Thank you! Record UPDATED Successfully!<br>You'll be redirected to Home Page after (1) Seconds";
          echo "<meta http-equiv=Refresh content=1;url=table.php>";
}
elseif($accode)
{

        $result = mysql_query("SELECT * FROM city WHERE accode='$accode' ");
        $myrow = mysql_fetch_assoc($result);

                $code = $myrow["code"];
                $city = $myrow["name"];
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<link rel="stylesheet" type="text/css" href="form2/view.css" media="all">
<script type="text/javascript" src="form2/view.js"></script>
<script type="text/javascript" src="form2/calendar.js"></script>
</head>
<body id="main_body" >

    <img id="top" src="form2/top.png" alt="" />
    <div id="form_container">

        <h1><a>City</a></h1>
        <form id="city" class="appnitro" enctype="multipart/form-data" method="post" action="cityproc.php">
                    <div class="form_description">
        <h2>City</h2>
                <table border="0" width="100%">
                    <tr>
                        <td><?php echo $accode; ?></td>
                    </tr>
            </table>

        </div>
                    <table border ="0px" width="100%">
                        <input type="hidden" value="<? echo $myrow['accode']?>" name="accode"></input> 
                        <tr>
                            <td><label class="description" for="element_1">Code</label></td><td><input  name="code"  type="text" maxlength="6"  Placeholder="Please enter a code" value="<?php echo $code; ?>" disabled="disabled" /></td>
                        </tr>
                        <tr>
                            <td><label class="description" for="element_1">Name</label></td><td><input  name="city" size="40" type="text" maxlength="40" Placeholder="Please enter a name" value="<?php echo $city; ?>"/></td>

                        </tr>
                        <tr>
                            <td></td><td colspan="2" align="center"><input type="submit" name="submit" value="Save" /></td>
                        </tr>
                    </table>
                </form>
                </body>
    </html>
<?php
}
?>
  • 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-17T13:38:01+00:00Added an answer on June 17, 2026 at 1:38 pm
            $city = mysql_real_escape_string($_POST['city']);
            if(!empty($city)) {
                try {
                    $result = mysql_query("UPDATE `city` SET `name`= '$city' WHERE accode='$accode'");
                } catch (Exception $e) {
                    var_dump($e->getMessage()); // see what's the error.
                }
    
                if ($result) {
                    echo $result;
                } else {
                    echo $result;
                }
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ajax call to a php script that updates my MySQL DB
I have a simple php/mysql script that stores in mysql database id, link, and
I have this ajax_update script that updates file.php every 60 seconds.. Now file.php outputs
I have a script in MySQL that creates two tables, the second table references
I have a PHP script which runs a MySQL query. $query = INSERT INTO
I have the following script that successfully retrieves the current track and updates my
I have a MySQL database where I am storing information that is entered from
I have a script doing a mysql query and populate a table using $('#results').html(returnData);
Okay so I have a PHP script that makes a user an artist if
I have a script that waits until some row in a db is updated:

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.