我的更新腳本無法正常工作..我不知道什麼即時消失.. 但我無法更新表...去過w3school瞭解更新在PHP但仍不會工作... -noob coder-更新無法正常工作我找不到我的錯誤
<?php
include 'Core/init.php';
protect_page();
include 'Includes/Overall/overallheader.php';
?>
<h1>Update School Year and Semester</h1>
<?php
$con=mysqli_connect("localhost","root","1234","database3");
// Check connection
$sy = $_POST['school_year'];
$sem = $_POST['semester'];
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if (isset($_POST['submit']))
{
$sql = "UPDATE `activesys` SET `activeschoolyear` = '$sy' AND `activesemester` = '$sem'";
$exec = mysql_query($sql) or die(mysql_error());
}
?>
<form action="" method="post">
<ul>
<li>
School Year:<br />
<input type="text" name="school_year">
</li>
<li>
Semester:<br />
<input type="text" name="semester">
</li>
<li>
<input type="submit" value="submit">
</li>
</ul>
</form>
<?php
include 'Includes/Overall/overallfooter.php';
?>
不能混合到'mysqli的電話()'和'MySQL的()' - 只需使用'mysqli的()'。順便說一句,如果你想要很好的參考資料,請使用[PHP](http://www.php.net)網站。 – 2014-02-21 06:58:16
你得到什麼錯誤? *注意:*永遠不要參考w3schools教程,它有許多小故障在其中錯過指導用戶。 – Rikesh
你必須在更新查詢中加上逗號分隔值。 like 'update table_name set field = value1,field2 = value2 .....' 你已經把'和'代替了'逗號'。 –