PHP MYSQL update stament not working -


this code meant check submitted form values , update table, replaces field blank

any ideas gone wrong, please?

<form action = "update.php" method = "post">     <p>         new name: <input type "text" name="name">         <input type= "submit">     </p> </form> 
<?php   require ('/var/www/html/site1/connect_db.php'); if(!empty($_post['name']) && !is_numeric($_post['name'])) {     $name=$_post['name'];     $name=mysqli_real_escape_string($dbc,$query);     $name=strip_tags($name);       #$query='update customers set customername = '".$name."' customernumber=114';     $query = "update customers ". "set customername = $name"."where customernumber=114" ;     mysqli_query($dbc,$query); } else {     echo $name; }  $query = 'select * customers customernumber=103'; $result = mysqli_query($dbc,$query);  while ($row=mysqli_fetch_array($result, mysqli_num)) {     echo"<p>name : $row[1]</p>"; } mysqli_close($dbc);  ?> 

you updating customer number 114 selecting 103 out, name may blank.

your update statement needs have quotes around $name bit below:

$query = "update customers set customername = '$name' customernumber=114"; 

edit: please see parameterised query advice in question comments.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -