|
 |
|
แก้ error นี้ค่ะ Connect Failed! :Access denied for user 'ODBC'@'localhost' (using password: NO) |
|
 |
|
|
 |
 |
|

Code (PHP)
<?php
include ("chksession.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ดาน์โหลดไฟล์</title>
</head>
<body>
<h4 align="right"><?php echo "เข้าสู่ระบบ : $sess_username";?><h4>
<h3><?php echo "ตรวจคำตอบแบบทดสอบหลังเรียน";?></h3>
<p> [<a href="main.php">กลับหน้าหลัก</a>]
[<a href="logout.php">ออกจากระบบ</a>]<hr>
</p>
<?php
//เชื่อมต่อฐานข้อมูลด้วย mysqli
include("connect.php");
$db = @new mysqli("localhost", "", "", "test_fu");
if(mysqli_connect_errno()) die("Connect Failed! :" . mysqli_connect_error());
$db->set_charset("utf8");
if(isset($_POST['Submit'] ))
{
$num_file = count($_FILES['file']['name']);
$select = false;
$count = 0;
for($i = 0; $i < $num_file ; $i++) //เนื่องจาก upload แบบ array เราจึงใช้ loop จัดการทีละไฟล์
{
if($_FILES['file']['error'][$i] != 0) //ถ้าเกิดข้อผิดพลาดให้ข้ามไฟล์นนี้ไป
{
$count++;
continue;
}
if($_FILES['file']['name'][$i] != "")
{
$Filename = $_FILES['file']['name'][$i];
$type = $_FILES['file']['type'][$i];
//เก็บชื่อไฟล์เป็นเวลาขณะที่ upload แล้วตามด้วยนามสกุลไฟล์ ถ้าไฟล์มีชื่อเหมือนกันจะได้ไม่มีปัญหา
//สามารถ upload ไฟล์นามสกุล .gif, .png, .jpg, .zip, .docx, .pdf, .doc, .swf, .rar ได้
$time = time() * microtime();
if ( $type == "image/gif" ) {$Filename = $time.".gif"; $pic_type = 'GIF'; }
else if ( $type == "image/png" ) {$Filename = $time.".png"; $pic_type = 'PNG'; }
else if (( $type == "image/jpg") or ($type=="image/jpeg") or ($type == "image/pjpeg")) {$Filename = $time.".jpg"; $pic_type = 'JPG'; }
else if ($type == "application/octet-stream" ) {$Filename = $time.".zip"; $pic_type = false;}
else if ($type == "application/vnd.openxmlformats-officedocument.wordprocessingml.document" ) {$Filename = $time.".docx"; $pic_type = false;}
else if ($type == "application/pdf" ) {$Filename = $time.".pdf"; $pic_type = false;}
else if ($type == "application/msword" ) {$Filename = $time.".doc"; $pic_type = false;}
else if ($type == "application/x-shockwave-flash" ) {$Filename = $time.".swf"; $pic_type = false;}
else if($type == "application/octet-stream" ) {$Filename = $time.".rar"; $pic_type = false;}
//move ไฟล์ไปยังโฟลเดอร์ที่สร้างไว้ในที่นี้คือ fileupload
if(move_uploaded_file($_FILES['file']['tmp_name'][$i], 'fileupload/'.$Filename)){
//จัดเก็บชื่อไฟล์ลงฐานข้อมูล
$sql = $db->query("INSERT INTO uploadfile (filename) VALUES ('{$Filename}') ");
if($sql)
{
echo "Upload สำเร็จ <br>";
$upload_true = true;
}else{
echo "Upload ล้มเหลว!! <br>";
}
}
}else{
$count++;
}
}
if($upload_true)
echo "<a href='show.php'>View file</a>";
}else{
echo "คุณยังไม่ได้เลือกไฟล์ Upload";
}
?>
Tag : PHP, MySQL, HTML/CSS

|
|
 |
 |
 |
 |
Date :
2012-10-14 02:54:54 |
By :
yah |
View :
4961 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
include("connect.php");
$db = @new mysqli("localhost", "", "", "test_fu");
ใช้ Password ไม่ถูกครับ
|
 |
 |
 |
 |
Date :
2012-10-14 04:09:39 |
By :
่judas78 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
T T passwordในการเชื่อมต่อฐานข้อมูลถูกหรือป่าวครับ checkดูละยัง
|
 |
 |
 |
 |
Date :
2012-10-14 04:10:41 |
By :
matay107 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
include("connect.php");
$db = @new mysqli("localhost", "root", "รหัสผ่าน", "test_fu");
ลองแก้ดูคับ
|
 |
 |
 |
 |
Date :
2012-10-14 07:25:34 |
By :
nukedonut1 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|