几天以来一直在尝试清除我将图像上传到文件夹并链接到 MySQL 的错误。我已经发布了我的问题,但更改了一些代码,这就是我想再次发布它的原因。对不起,如果我垃圾邮件。
这是我的代码“adresse-bearbeiten.php”
<?php
require_once ('konfiguration.php');
$target = "images/";
$target = $target . basename( $_FILES['photo']['name']);
function sanitize( $input ){
return mysql_real_escape_string( htmlspecialchars( stripslashes( trim( $input ) ) ) );
}
if(isset($_POST['title']))
{
$title = sanitize($_POST['title']);
$description = sanitize($_POST['description']);
$applepart = sanitize($_POST['applepart']);
$partnumber = sanitize($_POST['partnumber']);
$productcode = sanitize($_POST['productcode']);
$compatibility = sanitize($_POST['compatibility']);
$image = sanitize($_FILES['photo']['name']);
$price = sanitize($_POST['price']);
$insert = mysql_query("INSERT INTO `adressbuch` (`title`,`description`,`applepart`,`partnumber`,`productcode`,`compatibility`,`photo`,`price`) VALUES ('$title','$description','$applepart','$partnumber','$productcode','$compatibility','$image','$price')");
if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['photo']['name']). " has been uploaded, and your information has been added to the directory";
}
else {
echo "Sorry, there was a problem uploading your file.";
}
if (!$insert)
{
die('Not saved: ' . mysql_error());
}
}
?>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<span>Neuer Eintrag:</span> <br />
<span>Title</span><input type="text" name="title" /> <br />
<span>Description</span><textarea cols="16" rows="5" name="description"></textarea> <br />
<span>Apple Part</span><input type="text" name="applepart" /> <br />
<span>Part Number</span><input type="text" name="partnumber" /> <br />
<span>Product Code</span><input type="text" name="productcode" /> <br />
<span>Compatibility</span><input type="text" name="compatibility" /> <br />
<span>Image</span><input type="file" name="photo" /> <br />
<span>Price</span><input type="text" name="price" /> <br />
<input type="submit" value="Speichern"/> <br />
</form>
MySQL的
CREATE TABLE IF NOT EXISTS `adressbuch` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`title` text,
`description` text,
`applepart` text,
`partnumber` text,
`productcode` text,
`compatibility` text,
`photo` text,
`price` text,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=26 ;
下面列出了我得到的错误
- 注意:未定义索引:/Users/fatih/Sites/phpform/neu/adresse-bearbeiten.php 第 11 行中的照片
- 注意:未定义索引:/Users/fatih/Sites/phpform/neu/adresse-bearbeiten.php 第 18 行中的照片
- 注意:未定义索引:/Users/fatih/Sites/phpform/neu/adresse-bearbeiten.php 第 23 行中的照片
- 抱歉,上传您的文件时出现问题。
如果有人能告诉我我做错了什么会很高兴吗?问候