0

I have an update function in my website, when I run my update.php the error comes up.

(This is the error)

Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\Xampp\htdocs\DBLogistic\update.php on line 9

(Here is my update.php)

<?php
include('connectdb.php');

if (isset($_POST['update'])) {

$sql ="UPDATE tbluser SET userNm='$_POST['newname']', userFullNm='$_POST['newfullname']', userEmail='$_POST['newemail']', userPhone='$_POST['newcontact']', userLvlId='$_POST['newlevel']', userStatus='$_POST['newstatus']' WHERE userId='$_POST['id']'"; //this is line 9

mysql_query($sql, $con);

}

?>

Thank you for help, do ask me for more information if needed.

Chi Yang
  • 154
  • 1
  • 14

2 Answers2

1
<?php
include('connectdb.php');

if (isset($_POST['update'])) {

$sql ="UPDATE tbluser SETuserNm='".$_POST['newname']."',      userFullNm='".$_POST['newfullname']."', userEmai l='".$_POST['newemail']."'...";
 //... Represents the rest of the query
mysql_query($sql, $con); }

?>

Use the quotes in the similar way.

twodee
  • 606
  • 5
  • 24
0

Change all '$_POST['value']' to "$_POST['value']" because it does not understand the value in ''.

rid
  • 61,078
  • 31
  • 152
  • 193