nikhar021 Posted April 23, 2008 Share Posted April 23, 2008 this code is a part of a program that is written for the administrator to update a record from a table its givin the error Parse error: syntax error, unexpected T_VARIABLE in C:\xampp\htdocs\project\adminupdatesubmit.php on line 34 the code is if(!empty($_POST['first1'])) { /*line 34=*/ $update1 = "UPDATE student1 SET first = "$_POST[first1]" WHERE id="$_POST[id2]", branch="$_POST[ branch2]""; $result1 = mysql_query($update1) or die(.mysql_error()); echo "First name updated" ; $count++; } pls help me wats the error Link to comment https://forums.phpfreaks.com/topic/102523-help-me-with-the-syntax/ Share on other sites More sharing options...
947740 Posted April 23, 2008 Share Posted April 23, 2008 if(!empty($_POST['first1'])) { /*line 34=*/ $update1 = "UPDATE student1 SET first = "$_POST[first1]" WHERE id="$_POST[id2]", branch="$_POST[ branch2]""; $result1 = mysql_query($update1) or die(.mysql_error()); echo "First name updated" ; $count++; } It was the quotations. $update1 is supposed to be "UPDATE student1 SET first = '_POST[first1]' WHERE id='$_POST[id2]', branch='$_POST[branch2]'"; EDIT: By the time I realized the real problem, DarkWater had already written the solution. Link to comment https://forums.phpfreaks.com/topic/102523-help-me-with-the-syntax/#findComment-524897 Share on other sites More sharing options...
DarkWater Posted April 23, 2008 Share Posted April 23, 2008 $update1 = "UPDATE student1 SET first = '{$_POST[first1]}' WHERE id='{$_POST[id2]}' AND branch='{$_POST['branch2']}'"; $result1 = mysql_query($update1) or die(mysql_error()); There you go. You need to use single quotes (since you're in a double quote section, or you could escape all the double quotes, which is annoying...), and you need to use curly braces on the array. Link to comment https://forums.phpfreaks.com/topic/102523-help-me-with-the-syntax/#findComment-524898 Share on other sites More sharing options...
nikhar021 Posted April 23, 2008 Author Share Posted April 23, 2008 IVE MADE THE CHANGES BUT HERE IS WAT IM GETTING IN MY BROWSER You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CS'' at line 1 Link to comment https://forums.phpfreaks.com/topic/102523-help-me-with-the-syntax/#findComment-524987 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.