我的PHP腳本如下:move_uploaded_file()以腳本沒有完成
<?php
require_once('connectvars.php');
$file = $_FILES['image']['name'];
$target = GW_UPLOADPATH . $file;
if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) {
$dbc = mysqli_connect(DB_HOST, DB_UN, DB_PW, DB_NAME) or die('Error connecting to the MySQL server');
$title = mysqli_real_escape_string($dbc, trim($_POST['title']));
$description = mysqli_real_escape_string($dbc, trim($_POST['content']));
$host = mysqli_real_escape_string($dbc, trim($_POST['host']));
$duration = mysqli_real_escape_string($dbc, trim($_POST['duration']));
$sn1 = mysqli_real_escape_string($dbc, trim($_POST['link1']));
$sn2 = mysqli_real_escape_string($dbc, trim($_POST['link2']));
$sn3 = mysqli_real_escape_string($dbc, trim($_POST['link3']));
$sn4 = mysqli_real_escape_string($dbc, trim($_POST['link4']));
$sn5 = mysqli_real_escape_string($dbc, trim($_POST['link5']));
$query = "INSERT INTO dyhamb (title, description, host, duration, file, sn1, sn2, sn3, sn4, sn5) VALUES ('$title', '$description', '$host', '$duration', '$file', '$sn1', '$sn2', '$sn3', '$sn4', '$sn5')";
$result = mysqli_query($dbc, $query);
if (!$result) {
echo 'failed';
} else {
echo 'success';
}
mysqli_close($dbc);
}
?>
當我跑我收到「失敗」的腳本返回,我不明白爲什麼。 $dbc
和$query
似乎都很好,因此不確定爲什麼$result
未定義。
你的片段指向我一個重複的數據庫條目,我忽略了。謝謝。 – Ryan 2012-04-28 14:46:52
很高興能幫到你! – 2012-04-28 20:26:22