在編寫了一大堆更加複雜的代碼之後,這個代碼給了我很多問題。簡單更新查詢不起作用?
簡單的形式
<form action="res/scripts/editsubscriber.php" method="post">
<label for="name">Name: </label>
<input name="name" type="text" value="<?php echo $name; ?>">
...etc, etc...
</form>
提交給該腳本:
include('appvars.php');
if(isset($_POST['submit'])){
$id = $_POST['id'];
$name = $_POST['name'];
$email = $_POST['email'];
$month = $_POST['month'];
$day = $_POST['day'];
$year = $_POST['year'];
$date = $_POST['date'];
$time = substr($date, 0, (stripos($date, " ")+1));
$time = str_replace($time, '', $date);
$created = $year.'-'.$month.'-'.$day.' '.$time;
$query = "UPDATE newslettersubscribers SET name = '$name', email = '$email', created = '$created' WHERE id = $id)";
mysqli_query($dbc, $query);
}
它的帖子,我贊同所有的變量,他們改變了就好了,但它仍然不會更新數據庫。有人請告訴我我錯過了什麼......
在一個側面說明:您的代碼是脆弱的[SQL注入(https://secure.wikimedia.org /維基/ EN /維基/ Sql_injection)! – Veger
在UPDATE語句結尾處關閉括號,但我沒有看到任何開頭的括號? – mcriecken
括號在行尾? –