php - Get variable isn't written to database -
i've got code
$cislonakupu=$_get['cislonakupu']; if($_request['command']=='update'){ $datum = date("j/m/y h:i:s", time()); $user1=mysql_query("select * `register` `username`='$session'"); $mu=mysql_query("select * `velikostiobj` `objednavkac`='$cislonakupu'");$cislonakupu=$_get['cislonakupu']; $customerid=mysql_insert_id(); $date=date('y-m-d'); $orderid=mysql_insert_id(); $max=count($_session['cart']); for($i=0;$i<$max;$i++){ $pid=$_session['cart'][$i]['productid']; $q=$_session['cart'][$i]['qty']; $price=get_price($pid); $cp=$_post['cp']; $velikots=$row['velikost']; $n= date('j/m/y h:i:s', strtotime($date. ' + 14 days')); while ($row=mysql_fetch_array($mu)) { $resultik=mysql_query("insert `objednavkyinfo`(cislonakupu,produkt,mnozstvi,cena,cislofaktury,username,datumnakupu,dorucitdodata,velikost,dorucspol) values ('$cislonakupu','$pid','$q','$price','$cislofaktury','$session','$datum','$n','$velikots','$cp')") or die(mysql_error()); } } header("location: shoppingcart.php?delete=ano"); }
i need write $velikots
, database.
if $velikots="some text";
- it's working
if $velikots=$row['velikost'];
- not working
where's problem?
you never fetch results. trying use results of query before fetch them database.
$row = mysql_fetch_assoc($mu); $velikots = $row['velikost'];
you should able remove while loop:
while ($row=mysql_fetch_array($mu)) { ... } // remove this.
please, don't use mysql_*
functions in new code. no longer maintained and officially deprecated. see red box? learn prepared statements instead, , use pdo or mysqli - this article decide which. if choose pdo, here tutorial. you wide open sql injections
Comments
Post a Comment