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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:33:36+00:00 2026-05-14T02:33:36+00:00

I am pretty new to PHP and I am trying to make an inventory

  • 0

I am pretty new to PHP and I am trying to make an inventory database. I have been trying to make it so that a user can enter a card ID and then amount the want to add to the inventory and have it update the inventory. For example someone could type in test and 2342 and it would update test. Here is what I have been trying with no success:

add.html

<body>
  <form action="add.php" method="post">
    Card ID: <input type="text" name="CardID" />
    Amount to Add: <input type="text" name="Add" />
    <input type="submit" />
  </form>
</body>
</html>

add.php

<?php
$link = mysql_connect('host', 'username', 'password');
 if (!$link){
    die('Could not connect: ' . mysql_error());
   }
 mysql_select_db("tdm_inventory", $link);
 $add = $_POST[Add]
 mysql_query("UPDATE cardLists SET AmountLeft = '$add' WHERE cardID = 'Test'");
 echo "test successful";
 mysql_close($link);
?>
  • 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-14T02:33:36+00:00Added an answer on May 14, 2026 at 2:33 am

    I think you are missing quotes around your POST value for one. You are also committing one of the cardinal sins of PHP development putting the variables right in your SQL string like that. Try this instead:

    <?php
     $link = mysql_connect('host', 'username', 'password');
     if (!$link)
     {
       die('Could not connect: ' . mysql_error());
     }
     mysql_select_db("tdm_inventory", $link);
     if (mysql_errno()) 
     { 
       echo mysql_errno($link) . ": " . mysql_error($link) . "\n";
     }
     $add = $_POST["Add"]
     $query = sprintf("UPDATE cardLists SET AmountLeft = AmountLeft + %s WHERE cardID = 'Test'", mysql_real_escape_string($add));
     mysql_query($query);
     if (mysql_errno()) 
     { 
       echo mysql_errno($link) . ": " . mysql_error($link) . "\n";
     }
     echo "test successful";
     mysql_close($link);
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to python and I have been trying to change my php
guys I'm pretty new for php i'm trying to make a login page. How
I'm pretty new to PHP and have a String which contains an HTML page.
I have a rough php script that sees if a user has filled in
I am pretty new to both php and mysql. I have a txt file
I'm pretty new to php but i'm learning pretty fast, I have a question
I am pretty new to both php and SQL. I have a login page
I'm pretty new to PHP and i'm trying to learn namespacing to a reasonable
I'm pretty new to Perl and trying to convert some PHP code to Perl.
Alright. I have several queries <?php // Make a MySQL Connection mysql_connect(mm.hostname.net, user, pass)

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.