Friday, October 21, 2011

PDO utf-8 issues

Had issues with json_encode complaining:
Invalid UTF-8 sequence in argument 

Fixed it by adding

PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"
to the PDO creation line.. ie:
$pdo = new PDO(
    'mysql:host=mysql.example.com;dbname=example_db',
    "username",
    "password",
    array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));


source

Tuesday, October 11, 2011

Emacs, geben and xdebug

* sudo pecl install xdebug
* edit php.ini
  zend_extension=/path/to/xdebug.so
; usually /usr/lib/php5/20060613+lfs/xdebug.so
  [debug]
  xdebug.remote_autostart=off
  xdebug.remote_enable=on
  xdebug.remote_handler=dbgp
  xdebug.remote_mode=req
  xdebug.remote_host=localhost
  xdebug.remote_port=9000
* restart apache: /etc/init.d/apache2 restart
* download geben: http://trac.sakura.ne.jp/geben/
* unpack it into ~/emacs.d/ (emacs includes folder) * add this to your .emacs file:
(add-to-list 'load-path "/home/your/emacs.files/geben")
(add-to-list 'load-path "/home/your/emacs.files/geben/gud")
* restart emacs and run geben with `M-x geben`
* open a php service with the parameter
`?XDEBUG_SESSION_START` to start debugging


source