mysqli改变表问题

时间:2015-08-29 19:08:35

标签: php mysqli alter-table

这就是我所拥有的:

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命令有效

1 个答案:

答案 0 :(得分:0)

这显然是一个空间问题。您的查询应该看起来像

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