|
|
|
ช่วยดูโค้ดให้หน่อยครับ มันไม่ลงฐานข้อมูล insert into table values...... |
|
|
|
|
|
|
|
<?
$host = "localhost";
$user = "root";
$passwd = "123456";
$dbname = "news";
mysql_connect($host,$user,$passwd) or die("ติดต่อ Host ไม่ได้");
mysql_select_db($dbname) or die("ติดต่อฐานข้อมูลไม่ได้");
$title = htmlspecialchars($title);
$detail = htmlspecialchars($detail);
$from = htmlspecialchars($from);
$txt = array(
":emo01:", ":emo02:", ":emo03:", ":emo04:", ":emo05:", ":emo06:", ":emo07:", ":emo08:", ":emo09:", ":emo10:", ":emo11:", ":emo12:", ":emo13:", ":emo14:", ":emo15:", ":emo16:", ":emo17:", ":emo18:",":emo19:", ":emo20:", ":emo21:", ":emo22:", ":emo23:",":emo24:",":emo25:",":emo26:",":emo27:");
$pic = array(
"1.gif","2.gif","3.gif","4.gif","5.gif","6.gif", "7.gif","8.gif", "9.gif","10.gif","11.gif","12.gif","13.gif","14.gif","15.gif","16.gif","17.gif","18.gif","19.gif","20.gif","21.gif","22.gif","23.gif","24.gif","25.gif","26.gif","27.gif");
for ($a=0 ; $a<sizeof($txt) ; $a++) {
$detail = eregi_replace($txt[$a],"<img src=\"emotions/$pic[$a]\">",$detail);
}
$detail = eregi_replace ( "\[b\]", "<b> " , $detail ) ;
$detail = eregi_replace ( "\[/b\]", " </b>" , $detail ) ;
$detail = eregi_replace ( "\[i\]", "<i> " , $detail ) ;
$detail = eregi_replace ( "\[/i\]", " </i>" , $detail ) ;
$detail = eregi_replace ( "\[u\]", "<u> " , $detail ) ;
$detail = eregi_replace ( "\[/u\]", " </u>" , $detail ) ;
$detail = eregi_replace(chr(13)," <br> ", $detail );
$detail = eregi_replace ("\[img\]([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]])\[/img\]", "<img src=\"\\1://\\2\\3\">",$detail ) ;
$detail = eregi_replace("(^|[>[:space:]\n])([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])([<[:space:]\n]|$)","<a href=\"\\2://\\3\\4\" target=\"_blank\">\\2://\\3\\4</a>", $detail );
$detail = eregi_replace("([[:alnum:]]+)@([^[:space:]]*)([[:alnum:]])([<[:space:]\n]|$)","<a href=mailto:\\1@\\2\\3\>\\1@\\2\\3</a>", $detail );
$path="photo";
$mcdate= date("YmdHis");
if(empty($picture))
{
echo "";
}
else
{
copy( $picture ,"$path/$mcdate.jpg");
$images = "$path/$mcdate.jpg";
$width=65;
$size=GetimageSize($images);
$height=round($width*$size[1]/$size[0]);
$images_orig = ImageCreateFromJPEG($images);
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
ImageJPEG($images_fin,"$path/i$mcdate.jpg");
ImageDestroy($images_orig);
ImageDestroy($images_fin);
$Year = date("Y")+543;
$thaimonthFull=array("มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม", "พฤศจิกายน","ธันวาคม");
$date = date("j "). $thaimonthFull[date("m")-1]." ".$Year;
$sql = "insert into topic (title,detail,from,date,picture) values ('$title','$detail','$from','$date','$mcdate.jpg')";
$result = mysql_db_query($dbname,$sql);
}
mysql_close();
?>
Tag : - - - -
|
|
|
|
|
|
Date :
4 พ.ย. 2548 14:58:39 |
By :
Mc-art |
View :
2250 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลอง echo $sql; ได้ค่าแล้วเอาไป Query บน phpMyAdmin นะครับ โปรแกรมจะแจ้ง Error ให้ทราบ
|
|
|
|
|
Date :
5 พ.ย. 2548 08:31:54 |
By :
@W_IN |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณครับ
|
|
|
|
|
Date :
5 พ.ย. 2548 12:46:42 |
By :
Mc |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|