알수 없는 에러
글쓴이: ant01 / 작성시간: 목, 2012/08/30 - 12:57오전
코드를 완성했다고 생각한 순간 db에 그림 저장이 제대로 되지 않아서
다시 프로그램 하는 중의 코드입니다.
이상한 것은 <script> </script>를 삽입 하기전에는 잘 작동하던 코드가 삽입 후에는 그림 데이터가 깨져 버리는 것입니다.
이것이 되야 진도 나가는 데 정말 고민 스럽습니다. 누가 알려 주시면 감사하겠습니다.
<script> </script> <?php $connect=mysql_connect("localhost","php","pki0606") or die(mysql_error()); mysql_select_db("shop0") or die("데이타베이스를 선택할 수 없습니다."); mysql_query("set names utf8"); if(empty($image)){ $image=$_FILES[image][tmp_name]; } $code=$_POST[geshifilter-code]; $model=$_POST[model]; $manufacturer=$_POST[manufacturer]; $type=$_POST[type]; $performance=$_POST[performance]; $price=$_POST[price]; if (!$_POST['uploaded']){ ?> <table border=0 align=center> <tr><td> 제품 등록 화면 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" ENCTYPE="multipart/form-data"> <table border=1 align=center> <tr> <td> 코드 :<td><input type=text name=code onkeypress="check_keys();" > <tr> <td> 모델 :<td><input type=text name=model> <tr> <td> 제조 :<td><input type=text name=manufacturer> <tr> <td> 타입 :<td><input type=text name="type"> <tr> <td> 성능 :<td><input type=text name=performance> <tr> <td> 사진 :<td><input type=file name=image> <tr> <td> 가격 : <td><input type=text name=price> <input type="hidden" name="uploaded" value="1"> <input type=submit value=저장하기> </form> <?php } else { if (!empty($image)){ $fp = fopen($_FILES[image][tmp_name], "r"); $contents = fread($fp, $_FILES[image][size]); fclose($fp); $encoded=mysql_escape_string($contents); //$encoded = chunk_split(base64_encode($contents1)); echo $contents; $query="INSERT INTO `shop0`.`test` (`no`, `code`,`picture`) VALUES (NULL, '2', '$encoded')"; $result=mysql_query($query,$connect); unlink($filename1); } } mysql_close($connect); ?>
Forums:
댓글 달기