我尝试在我的数据库中插入多行,该图像未保存到文件夹,
我收到此错误
Blockquote ArrayArray你的SQL语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在 'Chrysanthemum.jpg')、('Hydrangeas.jpg')'、'('Chrysanthemum.jpg')、('Hydrangeas.j' 行附近使用正确的语法1
这是我的代码:
$hopid = $_POST[photo_hop_id];
$title = $_POST['photo_name_id'];
if(!is_array($title)) {
$title = array();
}
$titleds = "('" . implode("'), ('", $title) . "')";
$tmp_file = $_FILES['ne_photo_image']['tmp_name'];
$file = $_FILES['ne_photo_image']['name'];
if(!is_array($tmp_file)) {
$tmp_file = array();
}
if(!is_array($file)) {
$file = array();
}
$sementara = "('" . implode("'), ('", $tmp_file) . "')";
$filed = "('" . implode("'), ('", $file) . "')";
$tmp_file1 = $_FILES['fe_photo_image']['tmp_name'];
$file1 = $_FILES['fe_photo_image']['name'];
if(!is_array($tmp_file1)) {
$tmp_file = array();
}
if(!is_array($file1)) {
$file = array();
}
$sementara1 = "('" . implode("'), ('", $tmp_file) . "')";
$filed1 = "('" . implode("'), ('", $file) . "')";
if(!move_uploaded_file($sementara, 'image/' . $filed)) {
echo $_FILES["ne_photo_image"]["error"];
}
if(!move_uploaded_file($sementara1, 'image/' . $filed1)) {
echo $_FILES["fe_photo_image"]["error"];
}
$y = "INSERT INTO photo VALUES (null, '".$filed."', '".$filed1."', '".$hopid."', '".$titleds."')";
$z = mysql_query($y) or die (mysql_error());
if($z) {
$msg = "Data sudah ditambahkan";
}
else {
$msg = "Data tidak bisa dimasukkan";
}
echo print_r($y);
这是我的表格:
<form method="post" enctype="multipart/form-data">
<table border="0"cellpadding="0" cellspacing="0" width= "100%">
<tr>
<td>Hop Name :<?echo "$data[hop_name]"?>
<input type='hidden' name='photo_hop_id' value='<?echo"$data[hop_id]"?>'>
</td>
</tr>
<table border="0"cellpadding="0" cellspacing="0" width= "100%">
<tr>
<td cellpadding="0" cellspacing="0" width= "50%">
Near End Site Name : <?echo "$data[ne_site_name]" ?>
</br>
Near End Site Id : <?echo "$data[ne_site_code]" ?>
</td>
<td cellpadding="0" cellspacing="0" width= "50%">
Far End Site Name : <?echo "$data[fe_site_name]" ?>
</br>
Far End Site Id : <?echo "$data[fe_site_code]"?>
</td>
</tr>
<tr>
<td cellpadding="0" cellspacing="0" width= "50%">
<? $pm1= mysql_query("SELECT photo_name FROM photo_name WHERE photo_name_id = 1");
$dpm1 = mysql_fetch_array ($pm1);echo"$dpm1[0]" ?>
<input type='hidden' name='photo_name_id[]' value='<?echo"$dpm1[0]"?>'> :
<input type="file" name="ne_photo_image[]">
</td>
<td cellpadding="0" cellspacing="0" width= "50%">
<?echo "$dpm1[0]"?> : <input type="file" name="fe_photo_image[]">
</td>
</tr>
<tr>
<td cellpadding="0" cellspacing="0" width= "50%">
<? $pm1= mysql_query("SELECT photo_name FROM photo_name WHERE photo_name_id = 2");
$dpm1 = mysql_fetch_array ($pm1);echo"$dpm1[0]" ?>
<input type='hidden' name='photo_name_id[]' value='<?echo"$dpm1[0]"?>'> :
<input type="file" name="ne_photo_image[]">
</td>
<td cellpadding="0" cellspacing="0" width= "50%">
<?echo "$dpm1[0]"?> : <input type="file" name="fe_photo_image[]">
</td>
</tr>
</table>
</table>
<input type="submit" value="insert" />
</form>
非常感谢您的帮助