Can't resolve mysql error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jwgrafflin
    New Member
    • Mar 2008
    • 7

    Can't resolve mysql error

    I keep getting the same error:
    Unable to update dataYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ssl='O',ecomme rce='O',reselle r='-',dedicated='-',vps='x',affil iate='CJ',green ='-' at line 1
    This code works just fine on another site, and all the other php pages work just fine. But this one is driving me nuts trying to figure out the problem.

    Code:
    <?php
    $hostname=$_POST['hostname'];
    $url=$_POST['url'];
    $established=$_POST['established'];
    $price=$_POST['price'];
    $diskspace=$_POST['diskspace'];
    $bandwidth=$_POST['bandwidth'];
    $econplan=$_POST['econplan'];
    $maillists=$_POST['maillists'];
    $platform=$_POST['platform'];
    $ssl=$_POST['ssl'];
    $ecommerce=$_POST['ecommerce'];
    $reseller=$_POST['reseller'];
    $dedicated=$_POST['dedicated'];
    $vps=$_POST['vps'];
    $affiliate=$_POST['affiliate'];
    $green=$_POST['green'];
    $au=$_POST['au'];
    $ca=$_POST['ca'];
    $uk=$_POST['uk'];
    $notes=$_POST['notes'];
    
    include("dbinfo.inc.php");
    
    $query="UPDATE webhosts SET hostname='$hostname',url='$url',established='$established',price='$price',diskspace='$diskspace',bandwidth='$bandwidth',econplan='$econplan',maillists='$maillists',platform='$platform',ssl='$ssl',ecommerce='$ecommerce',reseller='$reseller',dedicated='$dedicated',vps='$vps',affiliate='$affiliate',green='$green',au='$au',ca='$ca',uk='$uk',notes='$notes' WHERE hostname='$hostname'";
    @mysql_select_db($database) or die( "Unable to select database" . mysql_error());
    mysql_query($query) or die("Unable to update data" . mysql_error());
    echo "<center><table><tr><td>";
    echo "<h2>Record Updated</h2>";
    echo "</td></tr></table></center>";
    mysql_close();
    ?>
  • chaarmann
    Recognized Expert Contributor
    • Nov 2007
    • 785

    #2
    check your table "webhosts" if it has the column "reseller".

    Your code will work on one side and not on the other if the tables "webhosts" are different.

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      SSL is a reserved word in MySQL, so you cannot use it for a column name. See MySQL 5,0 reserved word
      See the approp. documentation for other MySQL versions.

      Ronald

      Comment

      • jwgrafflin
        New Member
        • Mar 2008
        • 7

        #4
        Yep. You nailed it. Changed the field name and it works just fine.

        Thanks.

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          I knew I would. Glad it is solved. See you around.

          Ronald

          Comment

          • chaarmann
            Recognized Expert Contributor
            • Nov 2007
            • 785

            #6
            Originally posted by ronverdonk
            SSL is a reserved word in MySQL, so you cannot use it for a column name.
            Ronald
            I thought about that first, too. But then he wrote "this code works fine on another site". So if it's a reserved word then how was it working "on another site" then? It should also have been crashed there. Maybe different versions?

            Comment

            • ronverdonk
              Recognized Expert Specialist
              • Jul 2006
              • 4259

              #7
              SSL is a reserved word starting with MySQL version 4.0. Maybe the other site ran a MySQL version < 4.0.

              See MySQL 3.23, 4.0 and 4.1 Reserved words

              Ronald

              Comment

              Working...