|
 |
|
ใส่โค๊ดอัพรูป แล้ว ไม่แสดงผลคร่า... นู๋ทำหน้า ลงทะเบียน แล้วมีการอัพรูป แต่เมื่อใส่โค๊ดอัพรูป แล้ว ไม่เก็บลง ดาต้าเบส |
|
 |
|
|
 |
 |
|
นู๋ทำหน้า ลงทะเบียน แล้วมีการอัพรูป แต่เมื่อใส่โค๊ดอัพรูป แล้ว ไม่เก็บลง ดาต้าเบส
แต่เอาโค๊ดอัพรูปออก เหลือแต่โค๊ด insert กลับลงฐานข้อมูล ควรจะแก้ตรงไหนดี
Code (PHP)
<?php
require_once('class.upload.php') ;
//$_SESSION['owner_id']=$_POST['Owner_ID'];
$hostname_connection = "localhost";
$database_connection = "vehicles";
$username_connection = "root";
$password_connection = "123456";
$connection = mysql_pconnect($hostname_connection, $username_connection, $password_connection)
or trigger_error(mysql_error(),E_USER_ERROR);
$cs1 = "SET character_set_results=tis620";
mysql_query($cs1) or die('Error query: ' . mysql_error());
$cs2 = "SET character_set_client = tis620";
mysql_query($cs2) or die('Error query: ' . mysql_error());
$cs3 = "SET character_set_connection = tis620";
mysql_query($cs3) or die('Error query: ' . mysql_error());
// ถ้าหากหน้านี้ถูกเรียก เพราะการ submit form
// ประโยคนี้จะเป็นจริงกรณีเดียวก็ด้วยการ submit form
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
// เริ่มต้นใช้งาน class.upload.php ด้วยการสร้าง instant จากคลาส
$upload_image = new upload($_FILES['image_name']) ; // $_FILES['image_name'] ชื่อของช่องที่ให้เลือกไฟล์เพื่ออัปโหลด
// ถ้าหากมีภาพถูกอัปโหลดมาจริง
if ( $upload_image->uploaded ) {
// ย่อขนาดภาพให้เล็กลงหน่อย โดยยึดขนาดภาพตามความกว้าง ความสูงให้คำณวนอัตโนมัติ
// ถ้าหากไม่ต้องการย่อขนาดภาพ ก็ลบ 3 บรรทัดด้านล่างทิ้งไปได้เลย
$upload_image->image_resize = true ; // อนุญาติให้ย่อภาพได้
$upload_image->image_x = 150 ; // กำหนดความกว้างภาพเท่ากับ 400 pixel
$upload_image->image_ratio_y = 135; // ให้คำณวนความสูงอัตโนมัติ
$upload_image->process( "upload_images" ); // เก็บภาพไว้ในโฟลเดอร์ที่ต้องการ *** โฟลเดอร์ต้องมี permission 0777
// ถ้าหากว่าการจัดเก็บรูปภาพไม่มีปัญหา เก็บชื่อภาพไว้ในตัวแปร เพื่อเอาไปเก็บในฐานข้อมูลต่อไป
if ( $upload_image->processed ) {
$image_name = $upload_image->file_dst_name ; // ชื่อไฟล์หลังกระบวนการเก็บ จะอยู่ที่ file_dst_name
$upload_image->clean(); // คืนค่าหน่วยความจำ
// เก็บชื่อภาพลงฐานข้อมูล
$insertSQL = sprintf("INSERT INTO `vehicles`.`owner` (`Owner_ID`, `Name`, `Lastname`, `Tel`, `Mail`, `Address`, `Imagess`, `Username`, `Password`, `Faculty`, `Department`, `Statuspeople`)
VALUES ('$Owner_ID','$Name','$Lastname','$Tel','$Mail','$Address','%s','$Username','$Password','$Faculty','$Department','$Statuspeople')",$image_name );
mysql_select_db($database_connection, $connection);
$Result1 = mysql_query($insertSQL, $connection) or die(mysql_error());
}// END if ( $upload_image->processed )
}//END if ( $upload_image->uploaded )
}
echo "";
mysql_close();
?>
รบกวนช่วยดูให้ทีนะคระ ขอบคุนคร่า
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-09-29 18:23:39 |
By :
dektatee |
View :
1367 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แก้ไข
`vehicles`.`owner` เป็น `vehicles`,`owner`
`Imagess` เป็น `Images` ตรงนี้จงใจตั้งชื่อ field Imagess เปล่า :>
แล้วสัญลักษณ์ ` เอาออกก็ได้น่ะครับ แต่ถ้ามีจุดประสงค์ก็เก็บไว้ได้
|
 |
 |
 |
 |
Date :
2009-09-29 23:12:36 |
By :
xbeginner01 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|