|
 |
|
Insert to MySql มีปัญหา มีคำถามครับ 1.ทำไมโค้ดผมถึงError ผิดตรงไหนอ่ะ |
|
 |
|
|
 |
 |
|
มีคำถามครับ
1.ทำไมโค้ดผมถึงError ผิดตรงไหนอ่ะ
2.ตรงฟิวด์Date ผมใส่date() เลยได้ใช่ไหมครับ ตอนนี้ผมใส่null ข้อมูลชนิดDateTime
3. ในMySQL ฟิวด์ต่างๆเช่น Date และ Float เราจะต้กงอระบุขนาดหมดเลยใช่ไหม แล้วDateระบุอย่างไร
4.News_ID ของผมอยากให้มันเป็นเลข00001 หลังจากนั้นเพิ่มขึ้นเรื่อยๆ แบบนี้ผมกำหนดในเบสให้มันเป็นออโต้อินครีส แล้วตอนAddข้อมูลหน้านี้ผมไม่ต้องส่งNews_idไปเลยได้ไหมครับ
ปล. Date คือ DateTime , News_ID คือ int, A และ BB คือ Folat
Code (PHP)
<html>
<head>
<title>Add</title>
</head>
<body>
<?
$objConnect = mysql_connect("xxx","Administrator","") or die("Error Connect to Database");
$objDB = mysql_select_db("database");
$strSQL = "INSERT INTO news ";
$strSQL .="(News_ID,A,BB,News_Header,News_Content,Source,Date,Picture_1, Picture_2,Picture_3,Author,News_Type) ";
$strSQL .="VALUES ";
$strSQL .="('00001','".$_POST["txtLat"]."','".$_POST["txtLng"]."' ,'".$_POST["txtNews_Header"]."','".$_POST["txtNews_Header"]."' ,'".$_POST["txtNews_Content"]."' ,'".$_POST["txtSource"]."',null,'".$_POST["txtPicture1"]."' ,'".$_POST["txtPicture2"]."','".$_POST["txtPicture3"]."' ,'".$_POST["txtAuthor"]."','".$_POST["txtNews_Type"]."')";
$objQuery = mysql_query($strSQL);
if($objQuery)
{
echo '<script language="JavaScript">';
echo 'location.replace("http://www.tig-gis.com/thaimap/News_backoffice.php")';
echo '</script>';
}
else
{
echo "Error Save [".$strSQL."]";
}
mysql_close($objConnect);
?>
</body>
</html>
ผลรันครับ
Error Save [INSERT INTO news (News_ID,Lat,Lng,News_Header,News_Content,Source,Date,Picture_1 ,Picture_2,Picture_3,Author,News_Type) VALUES ('00001','99,'99','NEWS HEADER','NEWS HEADER','aNEWS CONTENT','SOURCE',null,'PIC1','PIC2','PIC3','AUTHOR','TYPE')]
ขอบคุณล่วงหน้าครับ
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-01-22 16:14:51 |
By :
nutkit |
View :
2728 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองเอา Code นี้ไป Run ใน phpMyAdmin ครับ
Code
INSERT INTO news (News_ID,Lat,Lng,News_Header,News_Content,Source,Date,Picture_1 ,Picture_2,Picture_3,Author,News_Type) VALUES ('00001','99,'99','NEWS HEADER','NEWS HEADER','aNEWS CONTENT','SOURCE',null,'PIC1','PIC2','PIC3','AUTHOR','TYPE')
|
 |
 |
 |
 |
Date :
2009-01-22 18:53:51 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|