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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phobia1
    New Member
    • Oct 2009
    • 18

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

    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.
    Code:
    <?PHP
    
    // update.php
    
    require("./resources/globals.php") ;
    require("./resources/common.php") ;
    //echo $detail; 
    //echo $passdata;
    //echo $key;
    
    $updateStmt = "Update Garant SET 
    akey='$akey',
    Ref='$Ref',
    Broker='$Broker',
    Brokerphone='$Brokerphone',
    Brokeremail='$Brokeremail',
    Comments='$Comments',
    BGComments='$BGComments',
    Price='$Price',
    Location='$Location',
    Town='$Town',
    smallpic='$smallpic',
    Pic1='$Pic1',
    Pic2='$Pic2',
    Pic3='$Pic3',
    Pic4='$Pic4',
    Portfolio='$Portfolio',
    Size='$Size',
    Condition='$Condition',
    Plotsize='$Plotsize',
    Roadaccess='$Roadaccess',
    Distance='$Distance',
    type='$type',
    Electricity='$Electricity',
    Water='$Water',
    garage='$garage',
    bedrooms='$bedrooms',
    Kitchen='$Kitchen',
    Status='$Status',
    WC='$WC' WHERE akey = '$akey' ";
    
    // Connect to the Database
    if (!($link=mysql_connect($location,$userName,$password))) {
       DisplayErrMsg(sprintf("error connecting to host %s, by user %s",$location,$userName)) ;
      exit() ;
    }
    
    // Select the Database
    if (!mysql_select_db($dbname, $link)) {
       DisplayErrMsg(sprintf("Error in selecting %s database", $dbname)) ;
       DisplayErrMsg(sprintf("error:%d %s", mysql_errno($link), mysql_error($link))) ;
       exit() ;
    }
    
    // Execute the Statement
    if (!mysql_query($updateStmt, $link)){
    
    // Execute the Statement/if (!mysql_query($updateStmt, $link)) {
      DisplayErrMsg(sprintf("Error in executing %s stmt", $updateStmt)) ;
     DisplayErrMsg(sprintf("error:%d %s", mysql_errno($link), mysql_error($link))) ;
      exit() ;
    }
    echo $updateStmt;
    GenerateHTMLHeader("The entry was modified succesfully");
    
    ReturnToDisplay( );
    
    ?>
    Its giving error from the mysql_query section in the form of
    Error in executing Update Garant SET akey='120',Ref= 'D127',Broker=' Dilyana',Broker phone=' +359xxxxxxxxx +359xxxxxxxxx ',Brokeremail=' dilyana@example .net',Comments= 'Traditional 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',Locati on='Veliko Tarnovo',Town=' Veliko Tarnovo',smallp ic='d127sm.jpg' ,Pic1='d127a.jp g',Pic2='d127b. jpg',Pic3='d127 c.jpg',Pic4='d1 27d.jpg',Portfo lio='existing', Size='200',Cond ition='for renovation',Plo tsize='400',Roa daccess='good all year around',Distanc e='11 km to Zlataritsa',typ e='House',Elect ricity='yes',Wa ter='yes',garag e='-',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',Plo tsize='400',Roa daccess='good all year around',Dist' at line 1
    Could anyone push me in thr right direction please
    Last edited by Atli; Nov 20 '09, 02:11 PM. Reason: Added [code] tags and removed sensitive information.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    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 (`).
    [code=sql]
    -- This will cause an error!
    SELECT * FROM tbl WHERE Condition = true;

    -- This is OK
    SELECT * FROM tbl WHERE `Condition` = true;
    [/code]

    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.

    Comment

    • phobia1
      New Member
      • Oct 2009
      • 18

      #3
      Thanks

      Thanks, I new it was something to with MYSQL and PHP versions
      Once again thanks a lot.
      Best
      F

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by phobia1
        Thanks, I new it was something to with MYSQL and PHP versions
        Once again thanks a lot.
        Best
        F
        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.

        Comment

        Working...