Warning: date() [function.date]: It is not safe to rely on the system's timezone settings.
You are *required* to use the date.timezone setting or the date_default_timezone_set() function.
In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier.
We selected 'Asia/Krasnoyarsk' for '7.0/no DST' instead in ...
วิธีแก้ไข
<?php
date_default_timezone_set('Asia/Bangkok');
?>
ฟังก์ชัน date_default_timezone_set()
การใช้ฟังก์ชัน date_default_timezone_set() เพื่อตั้งค่า timezone
ตัวอย่างเช่น timezone
America/Los_Angeles
America/New_York
America/Sao_Paulo
Asia/Tokyo
Asia/Bangkok
รับเขียนโปรแกรมธุรกิจ SMEs ทุกประเภท เว็บไซต์ เว็บบล็อก AppWebBlog@gmail.com : O8-4511-9515
แสดงบทความที่มีป้ายกำกับ บันทึกเทคนิค แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ บันทึกเทคนิค แสดงบทความทั้งหมด
php 5.3 setcookie Warning: Cannot modify header information - headers already sent by .. แก้โดย บรรทัดที่ 1 วาง
ปัญหากวนใจเรื่องการเขียนเว็บไซต์ด้วยภาษา PHP 5.3 ยังมีเรื่องอีกอย่างที่ทำให้ต้องหาทางแก้ไข ซึ่งที่ผมเจอจะเป็นช่วงหน้า login ที่ต้องการส่งค่าที่ต้องการบางอย่างไปเก็บไว้ใน setcookie เพื่อเอาไว้ใช้งาน ทำให้เกิด ข้อความว่า
"Warning: Cannot modify header information - headers already sent by"
ขึ้นมาเลยหาข้อมูลวิธีแก้ไขและไปเจอเว็บเพจที่น่าสนใจเกี่ยวกับปัญหานี้ (http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php)
ลองอ่านดูนะครับ แต่ผมลองวางโค้ดแค่นี้ที่บรรทัดที่ 1 ของหน้าโค้ด คือ
<?php ob_start() ;?>
PHP 5.3 ทำไม Uncaught ReferenceError: ClearData is not defined ?
login_ok.php:18 Uncaught ReferenceError: ClearData is not defined
วันนี้เจอBug เกี่ยวกับ datetime ของ PHP 5.3 แสดงว่า "login_ok.php:18 Uncaught ReferenceError: ClearData is not defined" ดูที่โค้ดเขียนไว้ว่า
$date = date("Y-m-d H:i:s");
ให้แก้เป็น
$original_timezone = new DateTimeZone('UTC');
// Instantiate the DateTime object, setting it's date, time and time zone.
$datetime = new DateTime($original_datetime, $original_timezone);
// Set the DateTime object's time zone to convert the time appropriately.
$target_timezone = new DateTimeZone('Asia/Bangkok');
$datetime->setTimeZone($target_timezone);
// Outputs a date/time string based on the time zone you've set on the object.
$triggerOn = $datetime->format('Y-m-d H:i:s');
$date =$triggerOn;
จบ...
PHP : php.ini คืออะไร? ปรับแก้ยังไงให้ใช้งานได้ดีกับ server
ข้อมูลสรุปนี้ไม่พร้อมใช้งาน โปรด
คลิกที่นี่เพื่อดูโพสต์
ทำไม Browser ไม่มีข้อมูลกลับมาจาก Ajax ไป PHP ? วิธีแก้ PHP Version ที่คุณใช้ที่ localhost ให้มันตรงกันกับ ที่ server ที่คุณจะอัปเว็บไซต์
วันนี้(8 มี.ค.58) เพิ่งได้คำตอบ หลังจากที่งมโค้ดมาครบ 7 วันเต็ม กับเรื่องที่ทำให้ต้องสยองกับการเขียนโค้ด PHP ซึ่ง เรื่องก็มีอยู่ว่า ผมได้เขียนเว็บไซต์จนเสร็จเรียบร้อยแล้ว ต้องการอัปขึ้น server เพื่อเปิดผ่าน internet โดยที่ ขณะทำการรันผ่าน localhost มันสามารถแสดงผลได้อย่างถูกต้อง พร้อมที่จะส่งงานลูกค้าอยู่แล้ว เลยทำการอัปขึ้น server แล้วลองเล่นดูใหม่ ทุก browser ที่ผมใช้ สามารถรันเว็บผ่านหมดไม่เกิดปัญหาใดๆ (เหมือนภาพตัวอย่างที่ 1) จึงขับรถ จาก มหาสารคาม เข้า กรุงเทพ ไปถึงลูกค้า 5 โมงเย็นพอดี รีบเปิดให้ลูกค้าดูผ่าน browser ของลูกค้า ปรากฏว่า "ไม่มีตารางแสดงข้อมูลออกมา !!" .... งานเข้าแล้วสิ ทำไงดี ลองทุก browser เหมือนกันหมด (เหมือนภาพตัวอย่างที่ 2) เลยต้องรีบควัก ASUS Tablet (เพื่อนคู่ใจ ขอบอกยี่ห้อสักนิด) มาเปิดให้ลูกค้าดู .. เลยรอด แต่วันนั้นเลยอดเก็บค่างวด เลยไม่มีเงินเติมน้ำมันกลับบ้าน ต้องโทรไปขอยืมเงินคุณแม่ T-T น่าสงสารตัวเองจริงๆ กลับมาถึงบ้านรีบหาทางแก้ไขใหม่ อย่ารู้มั๊ยว่าแก้ยังไง หลังจากงมมาครบ 7 วัน ถามใครก็ไม่มีใครบอกได้เลย (หมายถึงบอกตรงๆนะ) ลองผิดลองถูกไปเรื่อยๆจนพบสาเหตุ อย่างรู้ไปอ่านต่ออีกทีนะครับ ขอพักมือแป๊ป..
![]() |
| ตัวอย่างที่ 1 แสดงข้อมูลออกมาถูกต้อง |
![]() |
| ตัวอย่างที่ 2 ไม่มีตารางแสดงข้อมูลออกมา |
C# ,SQLite ทำไมค้นหาจากช่วงวันที่แล้ววันที่ออกไม่หมด? วิธีแก้ ให้ใส่ DateTime() ซะนะ
![]() |
| ตัวอย่าง.. เลือกวันที่ 3 - 4 แต่ออกแค่วันที่ 4 วันเดียว |
คุณเคยเจอแบบนี้บ้างมั๊ย?
+ ปวดหัวกะเรื่องวันที่จริงๆ +
![]() |
| ตัวอย่าง.. โค้ดที่ใช้เป็นแบบนี้ |
ลองเอา SQL string ที่เขียนไว้ไปทดสอบดูที่ SQLite มันก็มีค่าออกมาถูกต้องทุกอย่าง อย่างที่อยากได้
![]() |
| ตัวอย่าง.. ข้อมูลที่ได้จาก SQLite ที่ใช้ Query string ออกมาถูกต้อง |
![]() |
| ตัวอย่าง.. แก้ปัญหาโดยการเพิ่ม DateTime() |
สุดยอดความง่าย (แต่ผมหามาหลายชั่วโมงเลยเชียว T-T)
แก้ปัญหาโดยการเพิ่ม DateTime( ) จบป่ะล่ะ!!
select
Dispensing.FK_Code_EachService as FK_Code_EachService,
Dispensing.NAME_MEDICINE as NAME_MEDICINE,
Dispensing.NUMBER_OF_TIME as NUMBER_OF_TIME ,
Dispensing.PRICE as PRICE,
Dispensing.wholesale_sale as wholesale_sale,
HistoryAndIncome.wholesale2 as wholesale2,
Dispensing.TOTAL_PRICE as TOTAL_PRICE ,
Dispensing.DATE_INSERT as DATE_INSERT,
Dispensing.FK_ID_CARD_EMPLOYEE as FK_ID_CARD_EMPLOYEE
from Dispensing join HistoryAndIncome on HistoryAndIncome.FK_ID_EACHSERVICE = Dispensing.FK_Code_EachService
where Dispensing.HIDE_SHOW = 1 and Dispensing.DELETE_ITEM = 1 and Dispensing.SALE_OK = 1 and
datetime(Dispensing.DATE_INSERT) between ('2015-03-03 00:00:00') and ('2015-03-04 22:41:59') order by Dispensing.DATE_INSERT desc
C# วิธีตัด String ที่ยาวๆ ให้ขึ้นบรรทัดใหม่ได้ แค่ใส่ @ หน้า ".." ก็สามารถ Enter ได้เลย
C#.net ,SQLite ทำไม ค้นหาข้อมูลแล้วข้อมูลไม่ขึ้น ? แก้โดยการใส่ชื่อ Field แทน * ก็จะทำให้ข้อมูลออกมาได้แล้ว
![]() |
| ตัวอย่าง.. คลิกปุ่มค้นหา แล้วข้อมูลไม่ออก ทั้งๆที่ SQL Query string น่าจะถูกแล้ว |
คุณเคยพบเหตุการณ์นี้หรือไม่?
+ หากคุณทำการค้นหาข้อมูลแล้วไม่ขึ้นจะทำยังไง +
ปัญหานี้สามารถตรวจสอบได้จากการ DEBUG จะพบกว่า Query ที่คุณใช้ถูกต้องแล้ว เพราะเมื่อเอาไปตรวจสอบที่ SQL จะสามารถมีข้อมูลออกมาถูกต้อง แต่ทำไม่ใน DataGridView ไม่ออก หรืออาจจะออกมาไม่ถูกต้อง![]() |
| ตัวอย่าง.. ดูในโค้ดที่ส่วน DataDridView1.DataSource ไม่มีอะไรออกมาเลย |
![]() |
| ตัวอย่าง.. แปะดู sql ที่ส่งมาก็น่าจะถูกต้องแล้ว |
![]() |
| ตัวอย่าง.. เอา sql query string ไปทดสอบใน SQL ก็ได้ข้อมูลออกมาถูกต้องทุกอย่าง |
วิธีแก้ไขแสนง่ายดาย เพียงแค่คุณเปลี่ยนจาก Select * From ... เป็น Select FieldName From ... คือการใส่ชื่อ Field แทน * ก็จะทำให้ข้อมูลออกมาได้แล้ว
![]() |
| ตัวอย่าง.. ใส่ชื่อ Field แทน * ก็จะทำให้ข้อมูลออกมา |
![]() |
| ตัวอย่าง.. ดูในโค้ดที่ส่วน DataDridView1.DataSource ข้อมูลออกมาแล้ว |
![]() |
| ตัวอย่าง.. คลิกปุ่มค้นหา แล้วข้อมูลออกถูกแล้ว |
สรุปว่า .. หากคุณแน่ใจแล้วว่าคุณทำทุกอย่างถูกต้องหมดแล้ว ให้ลองพิจารณาที่โครงสร้างของ SQL ให้เขียนในรูปแบบที่ถูกต้องที่สุดไว้ก่อน จะทำให้แก้ปัญหาเรื่องที่คล้ายๆกันนี้ได้ครับ
textbox active to enter
ทำยังไงให้ textbox กด enter แล้วเริ่มรัน sub ครับ?
คือที่ทำมันต้องกดปุ่มเอา แต่อยากให้พอกรอกข้อมูลเสร็จ กด enter แล้วเริ่มทำงานเลย ทำยังไงครับ? ขอบคุณมากครับ
ก็ใช้เหตุการ text1_KeyPress() เช่น
Private sub text1_KeyPress(KeyAscii as Integer)
if KeyAscii = 13 then ' ถ้ากด enter
คำสั่ง
...
end if
End sub
หรือไม่กดเรียก command ตัวนั้นมาเลยก็ได้
Private sub text1_KeyPress(KeyAscii as Integer)
if KeyAscii = 13 then ' ถ้ากด enter
call command1_Click
end if
End sub
คือที่ทำมันต้องกดปุ่มเอา แต่อยากให้พอกรอกข้อมูลเสร็จ กด enter แล้วเริ่มทำงานเลย ทำยังไงครับ? ขอบคุณมากครับ
ก็ใช้เหตุการ text1_KeyPress() เช่น
Private sub text1_KeyPress(KeyAscii as Integer)
if KeyAscii = 13 then ' ถ้ากด enter
คำสั่ง
...
end if
End sub
หรือไม่กดเรียก command ตัวนั้นมาเลยก็ได้
Private sub text1_KeyPress(KeyAscii as Integer)
if KeyAscii = 13 then ' ถ้ากด enter
call command1_Click
end if
End sub
connect pc to pocket pc by viaDB
Connect pc กับ pocket pc ด้วย viaDB ยังไง
Dim cnDB As ADOCE.Connection
Set cnDB = CreateObject("ADOCE.Connection.3.0")
cnDB.Provider = "ViaDB"
'---- the computer name or IP address that is running the ViaDB NT service
cnDB.Properties("ViaDB Remote Server") = "192.168.11.100"
'---- the OLE DB provider to use on the computer which is the ViaDB Remote Server (see above)
cnDB.Properties("ViaDB Remote Provider") = "SQLOLEDB"
'---- this is the computer name that is running SQL Server (if the same as ViaDB Remote Server then use "(local)" )
cnDB.Properties("Data Source") = "(local)"
'---- this is the database to connect to (i.e. Pubs)
cnDB.Properties("Initial Catalog") = "YourDB"
'---- this is a valid user id for your database
cnDB.Properties("User ID") = "sa"
'---- this is a valid password for your database
cnDB.Properties("Password") = ""
cnDB.Open
อ้างอิง : http://www.thaidev.com/board1/view.php?id=294&bn=board_vb
Dim cnDB As ADOCE.Connection
Set cnDB = CreateObject("ADOCE.Connection.3.0")
cnDB.Provider = "ViaDB"
'---- the computer name or IP address that is running the ViaDB NT service
cnDB.Properties("ViaDB Remote Server") = "192.168.11.100"
'---- the OLE DB provider to use on the computer which is the ViaDB Remote Server (see above)
cnDB.Properties("ViaDB Remote Provider") = "SQLOLEDB"
'---- this is the computer name that is running SQL Server (if the same as ViaDB Remote Server then use "(local)" )
cnDB.Properties("Data Source") = "(local)"
'---- this is the database to connect to (i.e. Pubs)
cnDB.Properties("Initial Catalog") = "YourDB"
'---- this is a valid user id for your database
cnDB.Properties("User ID") = "sa"
'---- this is a valid password for your database
cnDB.Properties("Password") = ""
cnDB.Open
อ้างอิง : http://www.thaidev.com/board1/view.php?id=294&bn=board_vb
Get parameter from other programs to my program
วิธีรับค่า Paramiter จากภายนอก เข้ามาใช้ใน *.exe
สมมติ
เราสร้างโปรแกรมบางอย่างเพื่อที่จะทำการ Process แล้ว
เราต้องการเรียกใช้มันจากอีกโปรแกรมหนึ่ง โดยต้องส่งค่าจากโปรแกรมนั้นเข้ามายัง โปรแกรมแรก
จะต้องทำดังนี้
- ที่ Form1_Load ของโปรแกรมแรก จะมีคำสั่ง Command() เพื่อที่จะเก็บค่า Paramiter ที่ถูกส่งเข้ามาเป็นแบบ String
สมมติ
เราสร้างโปรแกรมบางอย่างเพื่อที่จะทำการ Process แล้ว
เราต้องการเรียกใช้มันจากอีกโปรแกรมหนึ่ง โดยต้องส่งค่าจากโปรแกรมนั้นเข้ามายัง โปรแกรมแรก
จะต้องทำดังนี้
- ที่ Form1_Load ของโปรแกรมแรก จะมีคำสั่ง Command() เพื่อที่จะเก็บค่า Paramiter ที่ถูกส่งเข้ามาเป็นแบบ String
How to Convert Text file to PDF file
สมัครสมาชิก:
บทความ (Atom)
.png)


.png)













