2015-08-29 83 views
0

這是我有:mysqli的改變表問題

if($_POST['submit']) { 

    $newAward = new AwardCenter($mysqli); 
    $arrColumns = array("name", "description", "imageurl", "imagewidth", "imageheight", "autodays", "autorecruits", "category", "subcategory", "ghosts", "advancedwarfare", "blackops3"); 
    $arrValues = array($_POST['newawardname1'], $_POST['description1'], $_POST['imageurl1'], $_POST['imagewidth1'], $_POST['imageheight1'], $_POST['autodays1'], $_POST['autorecruits1'], $_POST['category1'], $_POST['subcategory1'], $_POST['ghosts1'], $_POST['advancedwarfare1'], $_POST['blackops31'],); 

    if($newAward->addNew($arrColumns, $arrValues)) { 

    $newAwardInfo = $newAward->get_info_filtered(); 

     $result = $mysqli->query("ALTER TABLE ".$dbprefix."clanawards_members ADD '".$newAwardInfo['name']."' INT(11) NOT NULL DEFAULT '0'"); 
    echo " 
     <div style='display: none' id='successBox'> 
      <p align='center'> 
       Successfully Added New Award: <b>".$newAwardInfo['name']."</b>! 
      </p> 
     </div> 

     <script type='text/javascript'> 
      popupDialog('Award Center: Location', '".$MAIN_ROOT."members/console.php?cID=".$cID."', 'successBox'); 
     </script> 
    "; 

    } 
} 

的問題是,在alter table不執行的。 add new command works

+1

您可能需要前綴變量 – user2182349

+0

前綴變量前的空格嗎?哪一個? –

+0

正在尋找Java,發現PHP。 | - ) – itwasntme

回答

0

這顯然是空間問題。您的查詢應該看起來像

"ALTER TABLE ".$dbprefix.".clanawards_members ADD ".$newAwardInfo['name']." INT(11) NOT NULL DEFAULT '0'" 
+0

查詢現在還不錯,仍然不運行更改 –

+0

好吧,嘗試在答案中發佈的修改後的查詢。 ,我沒有看到你正在執行查詢, – Rahul

+0

把'關掉變量,它的工作原理,一開始沒有看到。 –