Styles2304 Posted November 24, 2008 Share Posted November 24, 2008 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 More sharing options...
.josh Posted November 24, 2008 Share Posted November 24, 2008 post your form Link to comment https://forums.phpfreaks.com/topic/133949-error-in-sql-syntax-again/#findComment-697320 Share on other sites More sharing options...
PFMaBiSmAd Posted November 24, 2008 Share Posted November 24, 2008 The while() loop is never executed. Where and what is $_NumberOfBlocks being set to? Link to comment https://forums.phpfreaks.com/topic/133949-error-in-sql-syntax-again/#findComment-697321 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.