日期:2014-05-16  浏览次数:20471 次

上传图片出错,这段代码我以前用的时候没报错
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8/>
<title>War-game -Add Your score</title>
</head>
<body>
<h2>War game - add your score</h2>
<?php

         
        include 'error_report.php';
$photo_dir='images/';


if(!empty($_POST['submit']))
{
$first_name=$_POST['first_name'];
$last_name=$_POST['last_name'];
$score=$_POST['score'];
if(!file_exists($photo_dir))
{
mkdir($photo_dir);
}
if($_FILES['image_upload']['error']>0)
{
echo 'Error:'.$_FILES['image_upload']['error'].'<br/>';
}
else{
$dbc=mysqli_connect('localhost','root','pengyu2408','score_list')or die('error in connet');
$query="INSERT INTO score_lis(first_name,last_name,score) VALUES('$first_name','$last_name','$score')";
mysqli_query($dbc,$query)or die('error_2');
$gpy=move_uploaded_file($_FILES['image_upload']['tmp_name'],$photo_dir.$_FILES['image_upload']['name']);

echo '<p>Thanks for adding your new high score!</p>';
echo '<p><strong>FIRST_NAME:</strong>'.$first_name.'<br/>';
echo '<strong>LAST_NAME:</strong>'.$last_name.'</p>';
echo '<p><strong>Score:</strong>'.$score.'<br/></p>';
echo '<img src="' . $photo_dir. $_FILES['image_upload']['name']. '">';
echo '<p><a href="index_1.php">&lt;&lt;Back to hight score</a></p>';
//clear the score data to clear the form
$firet_name="";
$last_name="";
mysqli_close($dbc);
}
}
?>
<hr />
<form entype="multipart/form-data" method ="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<label for="name">FIRST NAME:</label>
<input type="text" id="first_name" name="first_name" /><br />
<label for="name">LAST NAME:</label>
<input type="text" id="last_name" name="last_name"/><br />
<label for="score">Score:</label>
<input type="text" id="score" name="score"/><br />
<input type="file" id="image_upload" name="image_upload"/><br />
<hr />
<input type="submit" value="ADD" name="submit"/>
</form>
</body>
</html>


这里报错信息显示未定义变量,这是什么情况?
------解决方案--------------------
你去看看addscore.php 39行看看,你这个代码不会就是addscore.php里吧