Jump to content

Error in SQL Syntax . . . again


Styles2304

Recommended Posts

Ok, not exactly sure why but for some reason, the query statement isn't being filled out. The error is caused by the fact that I'm trying to pass a query that is basically empty. So, here's the error:

Error 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 '' at line 1 with query UPDATE `About Us` SET

 

 

Now here's the code immediately arround it. I'm kind of at a loss, it seems to me that things are setup most likely sloppy but in a way that should work.

<?php
$BlockCount = 1;
      $BlockName = 'Block';
      $query = "UPDATE `" . $_SESSION['Title'] . "` SET ";
      
      while ($BlockCount <= $_NumberOfBlocks) {
        $BlockName = 'Block';
        $BlockName = $BlockName . $BlockCount;
        $FontColor = $_POST[$BlockName . 'FontColor'];
        $IncludeInNav = $_POST[$BlockName . 'IncludeInNav'];
        $DisplayNav = $_POST[$BlockName . 'DisplayNav'];
        $BlockTitle = $_POST[$BlockName . 'BlockTitle'];
        $BlockContent = $_POST[$BlockName . 'BlockContent'];
        if ($BlockCount == $NumberOfBlocks) {
          $query .= "`" . $BlockName . "FontColor` = '" . $FontColor . "', " .
          "`" . $BlockName . "IncludeInNav` = " . $IncludeInNav . ", " .
          "`" . $BlockName . "DisplayNav` = " . $DisplayNav . ", " .
          "`" . $BlockName . "BlockTitle` = '" . $BlockTitle . "', " .
          "`" . $BlockName . "BlockContent` = '" . $BlockContent . "';";
          $BlockCount ++;
        } else {
          $query .= "`" . $BlockName . "FontColor` = '" . $FontColor . "', " .
          "`" . $BlockName . "IncludeInNav` = " . $IncludeInNav . ", " .
          "`" . $BlockName . "DisplayNav` = " . $DisplayNav . ", " .
          "`" . $BlockName . "BlockTitle` = '" . $BlockTitle . "', " .
          "`" . $BlockName . "BlockContent` = '" . $BlockContent . "', ";
          $BlockCount ++;
        }
      }
      mysql_query($query,$link) or die("Error ". mysql_error(). " with query ". $query);
    }
?>

Link to comment
https://forums.phpfreaks.com/topic/133949-error-in-sql-syntax-again/
Share on other sites

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.