0

Can anyone tell me why this doesnt work, and returns syntax error please?

$sql4 = "update apiStreetCheckGeneral 
         set (BBAverageSpeed, BBSuperFastBBAvailable, BBCommentary)
             values ('$averagespeed', '$superfast', '$bbcommentary') 
         where PostCode='".$values['PostCode']."'";
CustomQuery($sql4);
2
  • what does the syntax error tell you? Commented Nov 24, 2014 at 12:53
  • set them one by one instead, no other way is accepted in MySQL Commented Nov 24, 2014 at 12:59

2 Answers 2

1

This is your query:

update apiStreetCheckGeneral set (BBAverageSpeed, BBSuperFastBBAvailable, BBCommentary)
     values ('$averagespeed', '$superfast', '$bbcommentary')
     where PostCode='".$values['PostCode'].

I am not aware of update syntax that uses a column list or values. Set each one individually:

update apiStreetCheckGeneral
     set BBAverageSpeed = '$averagespeed',
         BBSuperFastBBAvailable = '$superfast',
         BBCommentary = '$bbcommentary'
     where PostCode='".$values['PostCode']."'"

You should learn, however, to use parameterized queries especially for update statements.

Sign up to request clarification or add additional context in comments.

Comments

0

Use query like below

$sql4 = "update apiStreetCheckGeneral 
         set BBAverageSpeed = '$averagespeed', 
          BBSuperFastBBAvailable = '$superfast', 
          BBCommentary = '$bbcommentary'
          where PostCode='".$values['PostCode']."' ";
CustomQuery($sql4);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.