PHP update table in MySQL not working

前端 未结 2 552
野的像风
野的像风 2021-01-29 08:59

My php won\'t update my products table. I know my GET request worked as I tested it with echo to display the id. I am confused as to how I can get it to work? I think it may be

相关标签:
2条回答
  • 2021-01-29 09:10

    I think the problems are misusing of ' in one or both of these lines

     . "p_price = '" . $_POST["updateProductPrice"] . "', "
     . "p_stock = " . $_POST["updateProductStock"] . ", "
    

    If the type is string you need to use ' as you used in p_price otherwise if it is float or int you should not use ' as you did for p_stock.

    It seems you used wrong for these two field. Since the p_price would be float and p_stock is string.

     . "p_price = " . $_POST["updateProductPrice"] . ", "
     . "p_stock = '" . $_POST["updateProductStock"] . "' , "
    
    0 讨论(0)
  • 2021-01-29 09:25

    There are two issues with your query...

    You Have one extra comma before the Where Section and your missing delimeters on p_stock.

    Should be: "p_stock = '" . $_POST["updateProductStock"] . "' " and . "WHERE id='" . $_GET['id'] . "'";

    0 讨论(0)
提交回复
热议问题