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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:37:27+00:00 2026-06-18T07:37:27+00:00

I have a simple, unsecured, local database that I’m learning with (yes still using

  • 0

I have a simple, unsecured, local database that I’m learning with (yes still using MySQL for now) I can view my database rows in a table and click on an edit button which then displays the single record chosen with each column inside a text box to update and save. Here is my edit page.

<?php
$id = $_GET['id'];
$connect = mysql_connect("localhost", "XXXXXX", "XXXXXXX") or
die ("Check your connection.");
mysql_select_db("toner");
$quey1="select * from inventory where id ='".$id."'";
$result=mysql_query($quey1) or die(mysql_error());
?>
<html>
<form action="updateinfo.php" method="post">
<table>
<?php
while ($row=mysql_fetch_array($result))
{
?>
<tr>
  <td align="right">Partnumber:</td>
  <td align="left"><input type="text" name="partnumber" value="<?php echo $row['partnumber'];?>"/></td>
</tr> 
<tr>
  <td align="right">Description:</td>
  <td align="left"><input type="text" name="description" value="<?php echo $row['description'];?>"/></td>
</tr> 
<tr>
  <td align="right">Vendor:</td>
  <td align="left"><input type="text" name="vendor" value="<?php echo $row['vendor'];?>"/></td>
</tr> 
<tr>
  <td align="right">Price:</td>
  <td align="left"><input type="text" name="price" value="<?php echo $row['price'];?>"/></td>
</tr> 
<tr>
  <td align="right">Quantity:</td>
  <td align="left"><input type="text" name="quantity" value="<?php echo $row['quantity'];?>"/></td>
</tr> 
</table>
<br>
<input type="hidden" name="id" value="<?php echo $row['id'];?>"/>
<input type="submit" value="Edit/Update Toner">
<?php
 }
?> 
</form>
</html>

Here is my UPDATED updateinfo

<?php
mysql_connect("localhost","XXXXX","XXXXX") or die("Error: ".mysql_error()); 
mysql_select_db("toner");
$id =$_POST['id'];
$partnumber = $_POST['partnumber'];
$description = $_POST['description'];
$vendor = $_POST['vendor'];
$price = $_POST['price'];
$quantity = $_POST['quantity'];
$sql = "UPDATE inventory SET partnumber ='".$partnumber."',description ='".$description."',vendor ='".$vendor."',price ='".$price."',quantity ='".$quantity."' WHERE id ='".$id."'";
mysql_query($sql) or die ("Error: ".mysql_error());
echo "Updated successfully";
header( "refresh:10;url=toner.php" );
?>

After adding a primary key I’m able to update the DB however $id = $_POST[‘id’]; still gives an error, any assistance is appreciated. Thanks. Yes I’m aware its vulnerable to injection and that I should be using PDO or MySQLi but I’m still a beginner and this is where I’ve chosen to start learning. Thank you.

  • 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-18T07:37:28+00:00Added an answer on June 18, 2026 at 7:37 am

    the problem is because of partnumber,here you are again reseting the partnumber but the new one is not present in your database and because of that query does not update the new values.

    $sql = "UPDATE inventory SET description ='".$description."',vendor ='".$vendor."',price ='".$price."',quantity ='".$quantity."' WHERE partnumber = '".$partnumber."'";
    

    Solution

    Don’t again set the partnumber use it only in where clause.

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

Sidebar

Related Questions

I have a simple, unsecured, local database that I'm learning with (yes still using
I have simple php validation form that is halfway working. If you leave the
I have simple database - one table with 6 collumns. 3 of them i
I have simple win service, that executes few tasks periodically. How should I pass
I have simple serial port program that is supposed to read the serial port
I have simple WPF application where I using threads. E.g. In new thread I
I have simple login form in my website. In given requirements stands, that password
i have simple singleton that sets pdo object from factory class , in the
I have simple jQuery UI autocomplete, which was working and now it's not. The
I have simple project, where I'm using signalR, When page loads, signalR scripts are

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.