Heim  >  Artikel  >  Backend-Entwicklung  >  上传图片出错,这段代码小弟我以前用的时候没报错

上传图片出错,这段代码小弟我以前用的时候没报错

WBOY
WBOYOriginal
2016-06-13 11:54:54789Durchsuche

上传图片出错,这段代码我以前用的时候没报错

<!DOCTYPE html><br /><html><br />	<head><br />		<meta charset=utf-8/><br />		<title>War-game -Add Your score</title><br />	</head><br />	<body><br />		<h2>War game - add your score</h2><br />		<?php<br />	<br /> 	       		<br />       			include 'error_report.php';<br />			$photo_dir='images/';<br /><br /><br />			if(!empty($_POST['submit']))<br />			{<br />				$first_name=$_POST['first_name'];<br />				$last_name=$_POST['last_name'];<br />				$score=$_POST['score'];<br />				if(!file_exists($photo_dir))<br />				{<br />					mkdir($photo_dir);<br />				}<br />				if($_FILES['image_upload']['error']>0)<br />				{<br />					echo 'Error:'.$_FILES['image_upload']['error'].'<br/>';<br />				}<br />				else{<br />					$dbc=mysqli_connect('localhost','root','pengyu2408','score_list')or die('error in connet');<br />					$query="INSERT INTO score_lis(first_name,last_name,score) VALUES('$first_name','$last_name','$score')";<br />					mysqli_query($dbc,$query)or die('error_2');<br />						$gpy=move_uploaded_file($_FILES['image_upload']['tmp_name'],$photo_dir.$_FILES['image_upload']['name']);<br />					<br />					echo '<p>Thanks for adding your new high score!</p>';<br />					echo '<p><strong>FIRST_NAME:</strong>'.$first_name.'<br/>';<br />					echo '<strong>LAST_NAME:</strong>'.$last_name.'</p>';<br />					echo '<p><strong>Score:</strong>'.$score.'<br/></p>';<br />					echo '<img  src="' . $photo_dir. $_FILES['image_upload']['name']. '" alt="上传图片出错,这段代码小弟我以前用的时候没报错" >';<br />					echo '<p><a href="index_1.php"><<Back to hight score</a></p>';<br />					//clear the score data to clear the form<br />					$firet_name="";<br />					$last_name="";<br />					mysqli_close($dbc);<br />				}<br />			}<br />		?><br />		<hr /><br />		<form entype="multipart/form-data" method ="post" action="<?php echo $_SERVER['PHP_SELF'];?>"><br />			<label for="name">FIRST NAME:</label><br />			<input type="text" id="first_name" name="first_name" /><br /><br />			<label for="name">LAST NAME:</label><br />			<input type="text" id="last_name" name="last_name"/><br /><br />			<label for="score">Score:</label><br />			<input type="text" id="score" name="score"/><br /><br />			<input type="file" id="image_upload" name="image_upload"/><br /><br />		<hr /><br />			<input type="submit" value="ADD" name="submit"/><br />		</form><br />	</body><br /></html><br />


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

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn