我想更新表名称为变量的表。我可以很好地更新表,但是当我尝试将其设置为变量时会遇到问题。我可能只是不太了解语法。
bing
我也尝试过使用escape_string
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$table = "settings";
$tr_title = $_POST['tr_title'];
$tr_slogan = $_POST['tr_slogan'];
$tr_signin = $_POST['tr_signin'];
$tr_makeacall = $_POST['tr_makeacall'];
$statment = $connect->prepare(
'UPDATE $table SET
tr_title = :tr_title,
tr_slogan = :tr_slogan,
tr_signin = :tr_signin,
tr_makeacall = :tr_makeacall
');
$statment->execute(array(
':tr_title' => $tr_title,
':tr_slogan' => $tr_slogan,
':tr_signin' => $tr_signin,
':tr_makeacall' => $tr_makeacall
));
header('Location: ' . $_SERVER['HTTP_REFERER']);
}
我很确定我的语法即将结束。