开发者

Form script not updating MySQL Database

开发者 https://www.devze.com 2023-01-30 16:08 出处:网络
I have a very simple form on a webpage. It contains a product description followed by a textbox (Quantity box) where the user can enter a new quantity, and then a price next to the textfield.

I have a very simple form on a webpage. It contains a product description followed by a textbox (Quantity box) where the user can enter a new quantity, and then a price next to the textfield.

When the update button is clicked, it should update the database.

The name's of the textfields correspond to the product that they are entering开发者_运维问答 a new value (quantity) for.

Zero errors are being generated. I have used print_r($_POST); to see what's being sent, if anything:

I would greatly appreciate any help at all, thank you so much.

jase


$key and $value are not defined, since your for loop is naming the variable $id and $data

foreach($_POST as $id=>$data)


There are a couple things you can try to help troubleshoot. Try using mysql_real_escape_string with the key variable. If the column's are integers, try removing single quotes and casting the value to insure value is an integer. For example:

mysql_query("INSERT INTO sessions (product, qty) VALUES ('". mysql_real_escape_string($id) . "', " . (int) $data . ")") or die(mysql_error());
0

精彩评论

暂无评论...
验证码 换一张
取 消