HTML5 Meta tag

Meta tag  ใน  HTML 5 ต่างจาก HTML 4.01 ดังนี้

  • ไม่รองรับ scheme attribute อีกต่อไป
  • attribute ใหม่คือ charset ทำให้สะดวกในการกำหนด character encoding ได้สะดวกขึ้น

อ่านเพิ่มเติมได้ที่นี่  HTML 5 Tag Reference

InnoDB กับ Lock wait timeout exceeded!

ผมใช้ innoDB  ใน MySQL แล้วเจอข้อความ error นี้

Lock wait timeout exceeded; try restarting  transaction

วิธีแก้ปัญหาที่ทำตอนนี้คือเปลี่ยนกลับไปใช้ MyISAM เหมือนเดิมก่อน

Object Relational Mapper (ORM)

Object-relational mapping (ORMO/RM, and O/R mapping) in computer software is a programming technique for converting data between incompatible type systems in relational databases and object-oriented programming languages.


หากมีเวลาก็ทดลองใช้งาน ORM ต่างๆ ได้

CodeIgniter – Session Bug within object storage

ผมใช้ CodeIginter แล้วเจอ error เกี่ยวกับ session library แบบนี้

A PHP Error was encountered
Severity: 4096
Message: Object of class stdClass could not be converted to string
Filename: libraries/Session.php
Line Number: 715

ลองค้นดูในเน็ตแล้วพบว่าเป็นบั๊กของ session เกี่ยวกับ object storage วิธีการแก้ที่

โดยให้แก้ไฟล์ system/libraries/Session.php ที่บรรทัด 683 และ  714  จาก

$data[$key] = str_replace('\', '{{slash}}', $val);


if(!is_object($val))    $data[$key] = str_replace('{{slash}}', '\', $val);

force ssl

force ssl ด้วย php

< ?php
 if ( !$_SERVER['HTTPS'] ) {

อีกวิธีการหนึ่งคือใช้  .htaccess

วิธีที่ 1:

SSLOptions +StrictRequire
SSLRequire %{HTTP_HOST} eq ""
ErrorDocument 403

วิธีที่ 2:

SSLOptions +StrictRequire
SSLRequire %{HTTP_HOST} eq ""
ErrorDocument 403


top tips!

# top -b -n 1 | grep Mem
Mem: 1016656k total, 941892k used, 74764k free, 164588k buffers

# top -b -n 1 | grep Cpu
Cpu(s): 0.3%us, 0.3%sy, 0.1%ni, 99.0%id, 0.1%wa, 0.1%hi, 0.2%si, 0.0%st

-b : Batch mode operation
Starts top in ‘Batch mode’, which could be useful for
sending output from top to other programs or to a file.
In this mode, top will not accept input and runs until the
iterations limit you’ve set with the ‘-n’ command-line
option or until killed.

Set MySQL Auto Increment Manually

ในกรณีที่ต้องการกำหนดค่า auto increment ใหม่ สามารถทำได้ตามรายละเอีดข้างล่างนี้

I have a database table with a auto increment column for primary key. As the records being add and delete many times, the auto increment value will keep increasing.

Problem One:
If I have entered 10 records, and deleted 9th, 10th records. The next auto increment value will be 11, not 9.

Run a query:


This will reset the next auto increment value to current largest value in the auto increment column + 1. So, the auto increment value of next inserted record will start from 9.

Problem Two:
If I have entered 10 records, and deleted center records – 4th, 5th. I want to insert next record as 4th not 11th.

Run the following query:

SET insert_id = 4;
INSERT INTO tablename VALUES ('blah', '...');

This will add the next record into record 4th.

The SET insert_id = #(where # is the next auto increment value you want to use) will reset the next auto increament value, the next query(INSERT) you run will use your choice of value.

Note: only effective for the immediate next query, one time.


vBulletin – Language / Charset Problems – Things To Check

Language / Charset Problems – Things To Check

Some people encounter problems with garbled characters when using vBulletin with non-English languages. Here are some things you can check based on my experience troubleshooting these problems:
Make sure your HTML charset is appropriate to your forum language:

Read more:  Click here

Curl กับ safe_mode หรือ open_basedir

If you are trying to use CURLOPT_FOLLOWLOCATION and you get this warning:
Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set…

then you will want to read which says “Disabled CURLOPT_FOLLOWLOCATION in curl when open_basedir or safe_mode are enabled.” as of PHP 4.4.4/5.1.5.  This is due to the fact that curl is not part of PHP and doesn’t know the values of open_basedir or safe_mode, so you could comprimise your webserver operating in safe_mode by redirecting (using header(‘Location: …’)) to “file://” urls, which curl would have gladly retrieved.