By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,836 Members | 2,018 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,836 IT Pros & Developers. It's quick & easy.

Updated MySQL version - error:1064 You have an error in your SQL syntax

P: 18
Hi once again.
We have just changed our ISP and things that worked fine now do not, Obviously its in the differences of MYSQL and PHP versions.
Have fixed most of the problems but this UPDATE routine has got me foxed.
Expand|Select|Wrap|Line Numbers
  1. <?PHP
  2.  
  3. // update.php
  4.  
  5. require("./resources/globals.php") ;
  6. require("./resources/common.php") ;
  7. //echo $detail; 
  8. //echo $passdata;
  9. //echo $key;
  10.  
  11. $updateStmt = "Update Garant SET 
  12. akey='$akey',
  13. Ref='$Ref',
  14. Broker='$Broker',
  15. Brokerphone='$Brokerphone',
  16. Brokeremail='$Brokeremail',
  17. Comments='$Comments',
  18. BGComments='$BGComments',
  19. Price='$Price',
  20. Location='$Location',
  21. Town='$Town',
  22. smallpic='$smallpic',
  23. Pic1='$Pic1',
  24. Pic2='$Pic2',
  25. Pic3='$Pic3',
  26. Pic4='$Pic4',
  27. Portfolio='$Portfolio',
  28. Size='$Size',
  29. Condition='$Condition',
  30. Plotsize='$Plotsize',
  31. Roadaccess='$Roadaccess',
  32. Distance='$Distance',
  33. type='$type',
  34. Electricity='$Electricity',
  35. Water='$Water',
  36. garage='$garage',
  37. bedrooms='$bedrooms',
  38. Kitchen='$Kitchen',
  39. Status='$Status',
  40. WC='$WC' WHERE akey = '$akey' ";
  41.  
  42. // Connect to the Database
  43. if (!($link=mysql_connect($location,$userName,$password))) {
  44.    DisplayErrMsg(sprintf("error connecting to host %s, by user %s",$location,$userName)) ;
  45.   exit() ;
  46. }
  47.  
  48. // Select the Database
  49. if (!mysql_select_db($dbname, $link)) {
  50.    DisplayErrMsg(sprintf("Error in selecting %s database", $dbname)) ;
  51.    DisplayErrMsg(sprintf("error:%d %s", mysql_errno($link), mysql_error($link))) ;
  52.    exit() ;
  53. }
  54.  
  55. // Execute the Statement
  56. if (!mysql_query($updateStmt, $link)){
  57.  
  58. // Execute the Statement/if (!mysql_query($updateStmt, $link)) {
  59.   DisplayErrMsg(sprintf("Error in executing %s stmt", $updateStmt)) ;
  60.  DisplayErrMsg(sprintf("error:%d %s", mysql_errno($link), mysql_error($link))) ;
  61.   exit() ;
  62. }
  63. echo $updateStmt;
  64. GenerateHTMLHeader("The entry was modified succesfully");
  65.  
  66. ReturnToDisplay( );
  67.  
  68. ?>
Its giving error from the mysql_query section in the form of
Error in executing Update Garant SET akey='120',Ref='D127',Broker='Dilyana',Brokerphone =' +359xxxxxxxxx +359xxxxxxxxx ',Brokeremail='dilyana@example.net',Comments='Trad itional Bulgarian house in a village 22 km south east of Veliko Tarnovo. This aristocratic property has been a shop (the front two premises faced to the main street of the village). The house consists of two attached parts. The ground floor of the first one is a large stone cellar (water inside), connected to the former shop with internal stairs. The first floor consists of 3 rooms in good condition. The second part of the house consists of 2 rooms on the ground floor and another 2 rooms on the first floor with beautiful view of Elena Mountain. Shower room attached to the second part. A barn finishes the building. There are 3 fireplaces in the house. Private garden 400 sq m with car space. Fruit trees and vines. Price: 21000 EUR',BGComments='??????????????????? ?????????????? ?????? ?? ?????? 22 ???? ????????????????? ??? ????????? ??????????????. ? ????????????? - ??????? ??? ??????????????????, ???????? ? ????? ??????????? ?? ????? ??????????????? ?????? ??????????? ??????? ??? ?????????. ??????, ????????????? ??? ??? 2 ?????????????? ???????: ????? ?? ????????????? ?????????? ?????? ??????????? ??????????? ?? 3 ?????? ?? ?????????? ????????? ???????????????? ??? ????????? ????. ????????? ????? ??? ???????? ????? 2 ?????? ??? ?????????? ???? ?? ????? ?????? ??? ????????? ????, ????????????? ??? ????????????? ???????????? ????????? ?????? ????????????? ????????. ??????????? ?????? ?? ????????????????????????? ???????????????? ?????????????? ????????, ????????? ????? 2 ??????????? ?? ????????. ??????????? 400 ??2 ?? ????????? ?? ??????????????? ??? ??????. ???????????? ?? ??????. ?????: 21000 ???????',Price='21000',Location='Veliko Tarnovo',Town='Veliko Tarnovo',smallpic='d127sm.jpg',Pic1='d127a.jpg',Pi c2='d127b.jpg',Pic3='d127c.jpg',Pic4='d127d.jpg',P ortfolio='existing',Size='200',Condition='for renovation',Plotsize='400',Roadaccess='good all year around',Distance='11 km to Zlataritsa',type='House',Electricity='yes',Water=' yes',garage='-',bedrooms='3',Kitchen='-',Status='for sale',WC='-' WHERE akey = '120' stmt
error:1064 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 'Condition='for renovation',Plotsize='400',Roadaccess='good all year around',Dist' at line 1
Could anyone push me in thr right direction please
Nov 20 '09 #1

✓ answered by Atli

Hey.

That particular problem is happening because the word "CONDITION" is a reserved keyword in MySQL 5.

If you want to use it, you have to enclose it in back-ticks (`).
Expand|Select|Wrap|Line Numbers
  1. -- This will cause an error!
  2. SELECT * FROM tbl WHERE Condition = true;
  3.  
  4. -- This is OK
  5. SELECT * FROM tbl WHERE `Condition` = true;
  6.  
I find it best to just enclose all table and field names in back-ticks. It ensures that nothing like this will affect my code, even if the list of reserved words is expanded to cover words that it does not include today.

You can see the list of reserved words in the manual.

Share this Question
Share on Google+
3 Replies


Atli
Expert 5K+
P: 5,058
Hey.

That particular problem is happening because the word "CONDITION" is a reserved keyword in MySQL 5.

If you want to use it, you have to enclose it in back-ticks (`).
Expand|Select|Wrap|Line Numbers
  1. -- This will cause an error!
  2. SELECT * FROM tbl WHERE Condition = true;
  3.  
  4. -- This is OK
  5. SELECT * FROM tbl WHERE `Condition` = true;
  6.  
I find it best to just enclose all table and field names in back-ticks. It ensures that nothing like this will affect my code, even if the list of reserved words is expanded to cover words that it does not include today.

You can see the list of reserved words in the manual.
Nov 20 '09 #2

P: 18
Thanks, I new it was something to with MYSQL and PHP versions
Once again thanks a lot.
Best
F
Nov 20 '09 #3

Markus
Expert 5K+
P: 6,050
@phobia1
In fact, nothing at all to do with PHP. Everything to do with MySQL, though. In future, please do your best to make this distinction and post your question to the appropriate forum.

Also, the title of this thread (Changed isp and a few headaches, could anyone help) isn't very descriptive and will not help others searching the forum.

I will move your thread to the MySQL forum and also give a better thread title.

Mark.
Nov 20 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.