|
|
|
สวัสดีครับน้องใหม่มีเรื่องจะปรึกษาพี่ๆครับ ก่อนอื่นต้องสวัสดีพี่ๆทุกท่านเลยนะครับพอดีผมพึ่งหัดเล่น php |
|
|
|
|
|
|
|
Code (PHP)
<?php
# Global Config
include("config.inc.php");
$connect=mysql_connect($host,$rootadmin,$rootpassword);
$select=mysql_select_db($dbname);
$query="INSERT INTO board_answer (aID, qID, aImage, aName, aEmail, aTel, aIcq, aDetail, aDateAns, aIP, aStatus) VALUES ('', '$qID', '$picture', '$aName', '$aEmail', '$aTel', '$aIcq', '$aDetail', NOW(), '$aIP', '0')";
$result=mysql_query($query);
?>
เอาชื่อรูปและข้อความลงฐานข้อมูล
|
|
|
|
|
Date :
2009-08-19 14:28:58 |
By :
Sek-Artdrinker |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
<?php
if (($picture!=none) && (ereg("^image",$picture_type) || ereg("application/x-shockwave-flash",$picture_type))) { // check image type
$picture_path="./picture_comment"; // path file to be saved
# print "Local File : $picture <br>\n"; // file image detail
print "File name : $picture_name <br>\n"; // file image detail
printf ("Size : %d",($picture_size/1024)); // file image detail
print " KB. <br>\n";
print "Type : $picture_type <br>\n"; // file image detail
if ($picture_type=="image/gif") { // check image type
$imgtype="gif";
}
elseif (($picture_type=="image/pjpeg") || ($picture_type=="image/jpeg")) { // IE & Firefox
$imgtype="jpg";
}
elseif ($picture_type=="image/png") {
$imgtype="png";
}
elseif ($picture_type=="application/x-shockwave-flash") {
$imgtype="swf";
}
elseif ($picture_type=="image/bmp") {
$imgtype="bmp";
}
else {
$imgtype="";
}
$picture_name_new=time().".$imgtype"; // set image name
if (copy($picture,"$picture_path/$picture_name_new")) { // coppy image
# print "ÀÒ¾»ÃСͺ : $picture_name_new <br>\n"; // ok
}
else {
print "äÁèÊÒÁÒöãÊèÀÒ¾»ÃСͺä´é <br>\n"; // no ok
}
# Unlink picture from Temp
unlink ($picture);
$picture="$picture_name_new";
}
else {
if ($picture_name=="") {
print "äÁèÁÕÀÒ¾»ÃСͺ <br>\n";
}
elseif (!ereg("^image",$picture_type) || !ereg("application/x-shockwave-flash",$picture_type)) {
print "äÁèãªè image file ËÃ×Í flash file<br>\n";
}
else {
print "ÀÒ¾»ÃСͺ¢¹Ò´à¡Ô¹ 150 Kb <br>\n";
}
$picture="";
}
# End Upload picture
?>
ก้อบรูปที่เลือก ลงโฟลเดอร์
?>
|
|
|
|
|
Date :
2009-08-19 14:34:33 |
By :
Sek-Artdrinker |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอาทั้ง 2 โคตที่ให้มาใส่ในหน้าเดียวเลยหรครับหรือแยกกันครับ
|
|
|
|
|
Date :
2009-08-19 14:56:43 |
By :
rescue_o |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แล้วแต่ครับ
|
|
|
|
|
Date :
2009-08-19 15:18:31 |
By :
Sek-Artdrinker |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
พี่ครับคือตอนนี้ผมอับโหลดได้แล้วครับแต่ว่า ตอนลบกับแก้ไขอะครับ
ตอนลบมันไม่ไปลบภาพในโฟล์เดอร์อะครับลบแต่ในฐานข้อมูลครับ
อันนี้โคตที่ผมใช้ลบอะครับต้องแก้ตรงใหนอะครับ
#<?php
mysql_query('SET NAMES tis620');
mysql_query('SET collation_connection tis620_thai_ci');
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
if ((isset($_POST['key_empid'])) && ($_POST['key_empid'] != "")) {
$deleteSQL = sprintf("DELETE FROM advertise_big WHERE `order`=%s",
GetSQLValueString($_POST['key_empid'], "text"));
mysql_select_db($database_bpcp, $bpcp);
$Result1 = mysql_query($deleteSQL, $bpcp) or die(mysql_error());
$deleteGoTo = "delete advertise big OK.php";
if (isset($_SERVER['QUERY_STRING'])) {
$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
$deleteGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $deleteGoTo));
}
$colname_advertise_big = "-1";
if (isset($_GET['empid'])) {
$colname_advertise_big = (get_magic_quotes_gpc()) ? $_GET['empid'] : addslashes($_GET['empid']);
}
mysql_select_db($database_bpcp, $bpcp);
$query_advertise_big = sprintf("SELECT * FROM advertise_big WHERE `order` = %s", $colname_advertise_big);
$advertise_big = mysql_query($query_advertise_big, $bpcp) or die(mysql_error());
$row_advertise_big = mysql_fetch_assoc($advertise_big);
$totalRows_advertise_big = mysql_num_rows($advertise_big);
?>#
ช่วยทีครับ
|
|
|
|
|
Date :
2009-08-21 12:55:11 |
By :
rescue_o |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
if ((isset($_POST['key_empid'])) && ($_POST['key_empid'] != "")) {
$deleteSQL = sprintf("DELETE FROM advertise_big WHERE `order`=%s",
GetSQLValueString($_POST['key_empid'], "text"));
mysql_select_db($database_bpcp, $bpcp);
$Result1 = mysql_query($deleteSQL, $bpcp) or die(mysql_error());
unlink("images/".$pic);
?>
ตัวนี้คือคำสั่งลบไฟล์ครับ unlink("images/".$pic);
|
|
|
|
|
Date :
2009-08-28 05:58:53 |
By :
biggoto |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|