Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > ช่วยเขียนโค๊ดเป็นตัวอย่างให้ทีครับ ลองเขียน ลองแก้ มาหลายครั้งไม่ได้ซักที ช่วยทีครับท่านผู้รู้ทั้งหลาย



 

ช่วยเขียนโค๊ดเป็นตัวอย่างให้ทีครับ ลองเขียน ลองแก้ มาหลายครั้งไม่ได้ซักที ช่วยทีครับท่านผู้รู้ทั้งหลาย

 



Topic : 073422



โพสกระทู้ ( 28 )
บทความ ( 0 )



สถานะออฟไลน์




datacar

ช่วยเขียนโค๊ดให้ทีครับ ผมลองหลายครั้งแล้วไม่ได้ซักที เกี่ยวกับการแทรก ข้อมูล และ บันทึก ข้อมูลเพิ่มเติมอะครับ
ช่วยที ผมลองเขียนแล้วมันเป็นแบบนี้ตลอดเลย ไม่สามารถบันทึกลง ดาต้าเบสได้ แก้หลายครั้งก็ไม่ได้ซักที รบกวน เขียนให้หน่อยครับ
อยากทาบว่า มันต้องแก้ไขตรงไหน

ไม่สามารถบันทึกได้ครับ [INSERT INTO datacar (idcar,car_name,model,type,coler, piston,horsepower,engine_number,vehicle_numbers, battery,volt,wheel,front_wheel,rear_wheel,type_rubber,width,long,high,weight,Load,factory, year,product_country,purchased_from,contract_number,price,type_oil,capacity) VALUES ('111','111','111' ,'111','111','111' ,'1111','111','111' ,'11','11','11' ,'11','111','11' ,'11','111','111' ,'111','111','1111' ,'111','111',' 111' ,'2222222','diesel','200' )]


ลองใส่เพิ่ม $objQuery = mysql_query($strSQL) or die mysql_error(); มันฟ้อง Query empty

ไม่รู้จะแก้ไงแล้ว ช่วยเขียนเป็นแนวทางให้ทีครับ



Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-02-07 18:40:40 By : preacher View : 1042 Reply : 11
 

 

No. 1



โพสกระทู้ ( 616 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Facebook

ลองดูดีีครับ คุณ กำหนดค่าที่จะ insert ไป 28 ตัว แต่ data ที่ส่งให่ มีแค่ 27 ตัว insert ยังไงก็ไม่เข้าครับ อ๋อ อีกอย่างครับ เห็นมี idcar ไม่ทราบว่าตั้งเป็ Auto Increment หรือป่าวครับ ถ้าเป็น ก็ไม่ต้องกำหนดค่าให้มันครับ ลองครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-02-07 18:49:14 By : slurpee55555
 


 

No. 2



โพสกระทู้ ( 28 )
บทความ ( 0 )



สถานะออฟไลน์


ไม่ได้ตั้งเป็น Auto Increment เพราะ idcar คือหมายเลขทะเบียนของรถอะครับ ไม่แน่ใจว่าต้องใช้ Auto Increment เลยไม่ได้กำหนดไว้
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-02-07 18:58:48 By : preacher
 

 

No. 3



โพสกระทู้ ( 616 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Facebook

งั้นก็ใส่ค่าให้ครบครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-02-07 19:06:03 By : slurpee55555
 


 

No. 4



โพสกระทู้ ( 28 )
บทความ ( 0 )



สถานะออฟไลน์


นี่โค๊ดครับ เปลี่ยน coler เป็น color แล้วนะครับ ชื่อ ฐาน car1 ชื่อตาราง datacar

<html>
<head>
<title>ARTILLERY CAR ADDSAVE</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","") or die("ไม่สามารถติดต่อฐานข้อมูลได้ครับ");
$objDB = mysql_select_db("car1");
$strSQL = "INSERT INTO datacar ";
$strSQL .="(idcar,car_name,model,type,color,piston,horsepower,engine_number,vehicle_numbers,battery,volt,wheel,front_wheel,rear_wheel,type_rubber,width,long,high,weight,Load,factory,year,product_country,purchased_from,contract_number,price,type_oil,capacity) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtidcar"]."','".$_POST["txtcar_name"]."','".$_POST["txtmodel"]."' ";
$strSQL .=",'".$_POST["txttype"]."','".$_POST["txtcolor"]."','".$_POST["txtpiston"]."' ";
$strSQL .=",'".$_POST["txthorsepower"]."','".$_POST["txtengine_number"]."','".$_POST["txtvehicle_numbers"]."' ";
$strSQL .=",'".$_POST["txtbattery"]."','".$_POST["txtvolt"]."','".$_POST["txtwheel"]."' ";
$strSQL .=",'".$_POST["txtfront_wheel"]."','".$_POST["txtrear_wheel"]."','".$_POST["txttype_rubber"]."' ";
$strSQL .=",'".$_POST["txtwidth"]."','".$_POST["txtlong"]."','".$_POST["txthigh"]."' ";
$strSQL .=",'".$_POST["txtweight"]."','".$_POST["txtLoad"]."','".$_POST["txtfactory"]."' ";
$strSQL .=",'".$_POST["txtyear"]."','".$_POST["txtproduct_country"]."','".$_POST["txtpurchased_from"]."' ";
$strSQL .=",'".$_POST["txtcontract_number"]."','".$_POST["txtprice"]."','".$_POST["txttype_oil"]."','".$_POST["txtcapacity"]."')";
$objQuery = mysql_query($strSQL);
if($objQuery)
{
echo "บันทึกเรียบร้อยแล้วครับ";
}
else
{
echo "ไม่สามารถบันทึกได้ครับ [".$strSQL."]";
}
mysql_close($objConnect);
?>
</body>
</html>


ผลออกมาแบบเดิม ครับ

ไม่สามารถบันทึกได้ครับ [INSERT INTO datacar (idcar,car_name,model,type,color,piston,horsepower,engine_number,vehicle_numbers,battery,volt,wheel,front_wheel,rear_wheel,type_rubber,width,long,high,weight,Load,factory,year,product_country,purchased_from,contract_number,price,type_oil,capacity) VALUES ('8829','นิสสัน','UG780' ,'รถยนต์บรรทุกปกติขนาดใหญ่','เขียว','6' ,'140','ND6-026175','UG780-24610' ,'2','24','44500' ,'900-20','900-20','ลมดัน' ,'2300','4470','-----' ,'4545','5165','นิสสัน' ,'1980','ญี่ปุ่น','ป.สยามกลการ จำกัด' ,'-------','274800','Diesel','200')]
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-02-07 19:35:19 By : preacher
 


 

No. 5



โพสกระทู้ ( 347 )
บทความ ( 0 )



สถานะออฟไลน์


ลองเปลี่ยนเป็น $objQuery = mysql_query($strSQL) or die (mysql_error()) ;
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-02-07 19:38:17 By : ozma
 


 

No. 6



โพสกระทู้ ( 28 )
บทความ ( 0 )



สถานะออฟไลน์


เปลี่ยนตรงไหนครับ
ตรงนี้เปล่าครับ $objQuery = mysql_query($strSQL);
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-02-07 19:40:01 By : preacher
 


 

No. 7



โพสกระทู้ ( 28 )
บทความ ( 0 )



สถานะออฟไลน์


ออกมาเป็นแบบนี้ครับ เพราะไร แก้ยังไงครับ ช่วยที

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'long,high,weight,Load,factory,year,product_country,purchased_fr
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-02-07 19:52:55 By : preacher
 


 

No. 8



โพสกระทู้ ( 616 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Facebook

ขอเอา code ด้านบนมาทำใหม่นะคับ Code (PHP)
<html>
<head>
<title>ARTILLERY CAR ADDSAVE</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","") or die("ไม่สามารถติดต่อฐานข้อมูลได้ครับ");
$objDB = mysql_select_db("car1");
$strSQL = "INSERT INTO datacar ";
$strSQL .="(idcar,car_name,model,type,color,piston,horsepower,engine_number,vehicle_numbers,battery,volt,wheel,front_wheel,rear_wheel,type_rubber,width,long,high,weight,Load,factory,year,product_country,purchased_from,contract_number,price,type_oil,capacity) ";
$strSQL .="VALUES ";
$strSQL .="('".$_POST["txtidcar"]."','".$_POST["txtcar_name"]."','".$_POST["txtmodel"]."' ";
$strSQL .=",'".$_POST["txttype"]."','".$_POST["txtcolor"]."','".$_POST["txtpiston"]."' ";
$strSQL .=",'".$_POST["txthorsepower"]."','".$_POST["txtengine_number"]."','".$_POST["txtvehicle_numbers"]."' ";
$strSQL .=",'".$_POST["txtbattery"]."','".$_POST["txtvolt"]."','".$_POST["txtwheel"]."' ";
$strSQL .=",'".$_POST["txtfront_wheel"]."','".$_POST["txtrear_wheel"]."','".$_POST["txttype_rubber"]."' ";
$strSQL .=",'".$_POST["txtwidth"]."','".$_POST["txtlong"]."','".$_POST["txthigh"]."' ";
$strSQL .=",'".$_POST["txtweight"]."','".$_POST["txtLoad"]."','".$_POST["txtfactory"]."' ";
$strSQL .=",'".$_POST["txtyear"]."','".$_POST["txtproduct_country"]."','".$_POST["txtpurchased_from"]."' ";
$strSQL .=",'".$_POST["txtcontract_number"]."','".$_POST["txtprice"]."','".$_POST["txttype_oil"]."','".$_POST["txtcapacity"]."')";
$objQuery = mysql_query($strSQL);
if($objQuery)
{
echo "บันทึกเรียบร้อยแล้วครับ";
}
else
{
echo "ไม่สามารถบันทึกได้ครับ [".$strSQL."]";
}
mysql_close($objConnect);
?>
</body>
</html>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-02-07 20:09:41 By : slurpee55555
 


 

No. 9



โพสกระทู้ ( 616 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Facebook

ลอง copy อันนี้ไปดูครับ

Code (PHP)
$strSQL .="('".$_POST["txtidcar"]."','".$_POST["txtcar_name"]."','".$_POST["txtmodel"]."'";
$strSQL .=",'".$_POST["txttype"]."','".$_POST["txtcolor"]."','".$_POST["txtpiston"]."'";
$strSQL .=",'".$_POST["txthorsepower"]."','".$_POST["txtengine_number"]."','".$_POST["txtvehicle_numbers"]."'";
$strSQL .=",'".$_POST["txtbattery"]."','".$_POST["txtvolt"]."','".$_POST["txtwheel"]."'";
$strSQL .=",'".$_POST["txtfront_wheel"]."','".$_POST["txtrear_wheel"]."','".$_POST["txttype_rubber"]."'";
$strSQL .=",'".$_POST["txtwidth"]."','".$_POST["txtlong"]."','".$_POST["txthigh"]."'";
$strSQL .=",'".$_POST["txtweight"]."','".$_POST["txtLoad"]."','".$_POST["txtfactory"]."'";
$strSQL .=",'".$_POST["txtyear"]."','".$_POST["txtproduct_country"]."','".$_POST["txtpurchased_from"]."'";
$strSQL .=",'".$_POST["txtcontract_number"]."','".$_POST["txtprice"]."','".$_POST["txttype_oil"]."','".$_POST["txtcapacity"]."')";


ได้ไม่ได้บอกด้วยนะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-02-07 20:13:46 By : slurpee55555
 


 

No. 10



โพสกระทู้ ( 28 )
บทความ ( 0 )



สถานะออฟไลน์


เหมือนเดิมครับ รับข้อมูลเข้าไม่ได้

ไม่สามารถบันทึกได้ครับ [INSERT INTO datacar (idcar,car_name,model,type,color,piston,horsepower,engine_number,vehicle_numbers,battery,volt,wheel,front_wheel,rear_wheel,type_rubber,width,long,high,weight,Load,factory,year,product_country,purchased_from,contract_number,price,type_oil,capacity) VALUES ('8829','นิสสัน','UG7802','รถยนต์บรรทุกปกติขนาดใหญ่','เขียว','6','140','ND6-026175','UG780-24610','2','24','44500','900-20','900-20','ลมดัน','2300','4470','5555','4545','5165','นิสสัน','1980','ญี่ปุ่น','ป.สยามกลการ จำกัด','08999999','274800','Diesel','200')]




พอใส่โค๊ด $objQuery = mysql_query($strSQL) or die (mysql_error()) ;

ผล เป็นอย่างนี้ครับ

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'long,high,weight,Load,factory,year,product_country,purchased_fr
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-02-07 20:30:51 By : preacher
 


 

No. 11



โพสกระทู้ ( 616 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Facebook

ติดคำสงวนหรือป่าวครับ
เปลี่ยน 3 ตัวนี้ครับ ตั้งชื่อใหม่ครับ ผมคิดว่าน่าจะเป็นคำสงวนครับ

( long load year )
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-02-07 20:54:47 By : slurpee55555
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยเขียนโค๊ดเป็นตัวอย่างให้ทีครับ ลองเขียน ลองแก้ มาหลายครั้งไม่ได้ซักที ช่วยทีครับท่านผู้รู้ทั้งหลาย
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่