php - MySQL Syntax Error During UPDATE -


if($_post['submit']) {     $day1 = $_post['day1'];     $day2 = $_post['day2'];     $day3 = $_post['day3'];     $day4 = $_post['day4'];     $day5 = $_post['day5'];     $day6 = $_post['day6'];     $day7 = $_post['day7'];     $day8 = $_post['day8'];     $day9 = $_post['day9'];     $day10 = $_post['day10'];     $day11 = $_post['day11'];     $day12 = $_post['day12'];     $day13 = $_post['day13'];     $day14 = $_post['day14'];      $query_update = ("update user_glucose set (day1='$day1',day2='$day2',day3='$day3',day4='$day4',day5='$day5',day6='$day6',day7='$day7',day8='$day8',day9='$day9',day10='$day10',day11='$day11',day12='$day12',day13='$day13',day14='$day14') username='$username'");      $result_update = mysql_query($query_update);     echo "data updated !";     echo"<p>";     echo mysql_error();     echo"</p>";   } 

i trying update value form table named "user_glucose". whenever click on submit error pops :

you have error in sql syntax; check manual corresponds mysql server version right syntax use near '(day1='10',day2='10',day3='0',day4='0',day5='0',day6='0',day7='0',day8='0',day9=' @ line 1

i new php , mysql programming , don't know problem. please help. thank you.

you don't need use parenthesis in update query, change to

    $query_update = ("update user_glucose set day1='$day1',day2='$day2',day3='$day3',day4='$day4',day5='$day5',day6='$day6',day7='$day7',day8='$day8',day9='$day9',day10='$day10',day11='$day11',day12='$day12',day13='$day13',day14='$day14' username='$username'"); 

then let know @ risk of sql injection, have here how can prevent sql injection in php?. should use prepared statment avoid risk


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

How can I fetch data from a web server in an android application? -

jquery - How can I dynamically add a browser tab? -