Adding with PHP to a MySQL database
Posted
by shinjuo
on Stack Overflow
See other posts from Stack Overflow
or by shinjuo
Published on 2010-03-22T20:27:31Z
Indexed on
2010/03/22
20:31 UTC
Read the original article
Hit count: 219
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('tulsadir.ipowermysql.com', 'cbouwkamp', '!starman1');
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);
?>
© Stack Overflow or respective owner