Jump to content

help me with the syntax


nikhar021

Recommended Posts

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

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.

$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.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.