2012-12-26 138 views
0

我試圖通過彈出窗口更新我的網站內容。我根據ID顯示內容,但是當我嘗試提交時彈出錯誤提示執行查詢時發生錯誤

執行查詢時發生錯誤。 請通知網絡開發者這個錯誤。

注意:您的SQL語法有錯誤;檢查手冊中 對應於你的MySQL服務器版本正確的語法使用 附近「WHERE文本ID = 16」在行1

我似乎無法找到的bug。你能看見它嗎?

這裏是我的完整代碼:

<!-- PHP --> 
<? 
    include('global.php'); 

    if(isset($_REQUEST['textID'])) 
     $textID = $_REQUEST['textID'];  
    if(isset($_REQUEST['textContent'])) 
     $textContent = $_REQUEST['textContent']; 

      if($_POST){ 
      $query = "UPDATE text_tb SET "; 
      $query = $query."textContent='".$textContent."', "; 
      $query = $query."WHERE textID=".$textID.""; 
      //echo $query; 
      ExecuteQuery($query); 
      echo "<script type=\"text/javascript\"> 
       <!-- 
       window.close(); 
       //--> 
       </script>"; 
      } 
?> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<title>Full featured example</title> 
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> 
<!-- TinyMCE --> 
<script type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script> 
<script type="text/javascript"> 
    tinyMCE.init({ 
     // General options 
     mode : "textareas", 
     theme : "advanced", 
     plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave,visualblocks", 

     // Theme options 
     theme_advanced_buttons1 : "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,fontselect,fontsizeselect", 
     theme_advanced_buttons2 : "bullist,numlist,|,undo,redo,|,link,unlink,|,forecolor", 
     theme_advanced_toolbar_location : "top", 
     theme_advanced_toolbar_align : "left", 
     theme_advanced_statusbar_location : "bottom", 
     theme_advanced_resizing : false, 

     // Example content CSS (should be your site CSS) 
     content_css : "css/content.css", 

     // Drop lists for link/image/media/template dialogs 
     template_external_list_url : "lists/template_list.js", 
     external_link_list_url : "lists/link_list.js", 
     external_image_list_url : "lists/image_list.js", 
     media_external_list_url : "lists/media_list.js", 

     // Style formats 
     style_formats : [ 
      {title : 'Bold text', inline : 'b'}, 
      {title : 'Red text', inline : 'span', styles : {color : '#ff0000'}}, 
      {title : 'Red header', block : 'h1', styles : {color : '#ff0000'}}, 
      {title : 'Example 1', inline : 'span', classes : 'example1'}, 
      {title : 'Example 2', inline : 'span', classes : 'example2'}, 
      {title : 'Table styles'}, 
      {title : 'Table row 1', selector : 'tr', classes : 'tablerow1'} 
     ], 
    }); 
</script> 
<!-- /TinyMCE --> 

</head> 
<body role="application"> 

<form method="post" action="<?php $_PHP_SELF ?>"> 
    <div> 
       <!-- Gets replaced with TinyMCE, remember HTML in a textarea should be encoded --> 
     <div> 
      <textarea id="textContent" name="textContent" rows="15" cols="80" style="width: 80%"> 
      <? 
      $result = mysql_query("SELECT * FROM text_tb WHERE textID ='".$textID."'"); 
           while($row = mysql_fetch_array($result)){ 
            echo $row['textContent']; 
           } 
      ?> 
      </textarea> 
     </div> 

     <!-- Some integration calls 
     <a href="javascript:;" onclick="tinyMCE.get('textContent').show();return false;">[Show]</a> 
     <a href="javascript:;" onclick="tinyMCE.get('textContent').hide();return false;">[Hide]</a>--> 
     <br /> 
     <input type="submit" name="save" value="Submit" /> 
     <input type="reset" name="reset" value="Reset" /> 
    </div> 
</form> 

<!--<script type="text/javascript"> 
if (document.location.protocol == 'file:') { 
    alert("The examples might not work properly on the local file system due to security settings in your browser. Please use a real webserver."); 
} 
</script>--> 
</body> 
</html> 
+0

當心[SQL注入](http://xkcd.com/327)。 –

回答

1

的問題是在設定的最後逗號。改變這一行:

 $query = $query."textContent='".$textContent."', "; 

到:

 $query = $query."textContent='".$textContent."' "; 
+0

我在那裏犯了一個小錯誤。非常感謝! – jamie

相關問題