PHP Add button malfunction -
i trying hard learn how create shop cart using php , seems me got stuck once more. time can not make "additional conditioning amount available in stock" work well. can me figure out wrong php code below?
if (isset($_get['add'])) { $con = mysqli_connect("localhost", "noivaemd_etalhes", "password", "***") or die (mysqli_error()); $quantity = mysqli_query($con, "select id, quantity products id=".mysqli_real_escape_string($con, $_get['add'])); echo '<p>'.$quantity_row['quantity']; while($quantity_row = mysqli_fletch_assoc ($quantity)) { if ($quantity_row['quantity']!=$_session['cart_'.$_get['add']]) { $_session['cart_'.$_get['add']]+='1'; } } }
many things.
you using
mysqli, nice stepmysql, you're still injecting values query. noteescape_stringnot here because did not put quotes around value, meaning you're still wide open injections. learn parameterised queries.you misspelled
fetchfletch.you using
+=string'1'. while php correct integer1via type coercion, it's still not thing writing because makes lack understanding.
these things visibly wrong code. if fixing these issues doesn't resolve problem, useful know error messages you're getting.
Comments
Post a Comment