|
 |
|
ช่วยหน่อยคับ php อัพรูปกะรายละเอียดรูปอัพรูปเข้าฐานข้อมูลแต่รายลเอียดไม่เข้าครับ |
|
 |
|
|
 |
 |
|
คือว่าผมเขียโคดอัพรูปและรายละเอียดของรูปคับแต่ว่าอัพได้แต่รูปอย่างเดียวที่เข้าฐานข้อมูล ส่วนรายละเอียดไม่เข้าฐานข้อมูลคับรบกวนผู้รู้ช่วยหน่อยคับ ขอบคุณล่วงหน้านะคับ
อันนี้ไฟล์ connect.php
<?
$host="localhost";
$user="root";
$pw="admin";
$dbname="dbkmc11";
$c= mysql_connect($host,$user,$pw);
$set1 = "SET character_set_results=tis620";
mysql_query($set1) or die('Error query: ' . mysql_error());
$set2 = "SET character_set_client = tis620";
mysql_query($set2) or die('Error query: ' . mysql_error());
$set3 = "SET character_set_connection = tis620";
mysql_query($set3) or die('Error query: ' . mysql_error());
if (!$c) {
echo "<h3>ERROR : äÁèÊÒÁÒöµÔ´µèÍ°Ò¹¢éÍÁÙÅä´é<h3>";
exit();
}
?>
อันนี้ไฟล์ admin.php
<html>
<head><title> PHOTO GALLERY </title></head>
<body>
<h2>ADMIN : PHOTO GALLERY</h2>
<form method = POST action = "insert.php"
ENCTYPE="multipart/form-data">
<table>
<tr>
<td><div align="right">ÃÙ»ÀÒ¾ : </div></td>
<td><input type="file" name="photo"></td>
</tr>
<tr>
<td valign="top"><div align="right">¤Ó͸ԺÒÂÃÙ»ÀÒ¾ : </div></td>
<td><textarea name="detail" rows ="4" cols="40"></textarea></td>
</tr>
<tr>
<td></td>
<td><input name="submit" type="submit" value="Submit">
<input name="reset" type="reset" value="Reset"></td>
</tr>
</table>
</form>
</body>
</html>
อันนี้ไฟล์ insert.php
<?
$photo=$_FILES['photo']['tmp_name'];
$photo_name=$_FILES ['photo'] ['name'];
$photo_size=$_FILES ['photo'] ['size'];
$photo_type=$_FILES ['photo'] ['type'];
$detail=$_post['detail'];
if (!$photo){
echo "<h3>ERROR : äÁèÊÒÁÒö UPLOAD ÃÙ»ÀÒ¾ä´é¤ÃѺ</h3>";
} else {
include "connect.php";
$array_last=explode (".",$photo_name);
$c=count($array_last) -1;
$lastname=strtolower ($array_last [$c]);
if ($lastname== "gif" or $lastname == "jpg" or $lastname == "jpeg") {
copy ($photo,"images/".$photo_name);
$sql= "insert into tb_photo
values (' ','$photo_name', '$detail')";
mysql_db_query ($dbname,$sql);
echo "<a href = 'admin.php'>
<h3>Upload ÃÙ»ÀÒ¾ àÃÕºÃéÍÂáÅéǤѺ </h3></a>";
}else{
echo "<h3>ERROR : ੾ÒÐÃÙ»ÀÒ¾¹ÒÁÊ¡ØÅ * .gif, *.jpg, *.jpeg à·èÒ¹Ñé¹ </h3> ";
}
unlink ($photo);
mysql_close ();
}
?>
อันนี้ฐานข้อมุลคับ
-- phpMyAdmin SQL Dump
-- version 2.10.2
-- http://www.phpmyadmin.net
--
-- โฮสต์: localhost
-- เวลาในการสร้าง: 17 ก.ย. 2009 น.
-- รุ่นของเซิร์ฟเวอร์: 5.0.45
-- รุ่นของ PHP: 5.2.3
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
--
-- ฐานข้อมูล: `dbkmc11`
--
-- --------------------------------------------------------
--
-- โครงสร้างตาราง `tb_photo`
--
CREATE TABLE `tb_photo` (
`id_photo` int(11) NOT NULL auto_increment,
`name_photo` varchar(50) NOT NULL,
`detail_photo` text NOT NULL,
PRIMARY KEY (`id_photo`)
) ENGINE=MyISAM DEFAULT CHARSET=tis620 AUTO_INCREMENT=12 ;
--
-- dump ตาราง `tb_photo`
--
ขอบคุณผู้ใจดีล่วงหน้านะคับ
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-09-17 17:02:48 |
By :
aody_1 |
View :
987 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 03
|