Friday, June 22, 2012

Get Texts or Values From HTML Select Code

header('Content-type: text/html; charset=utf-8');
echo $options = file_get_contents('options.txt');
if(!file_exists('options.txt')) {
  echo "file not exists";
}
preg_match_all('/([^>]*)<\/option>/', $options, $matches);
die('
'.print_r($matches, true).'
');

Compare MySQL Database Schema

Use this FREE tool: http://www.quest.com/toad-for-mysql/ 

Host xxx is not allowed to connect to this MySQL server

  1. Open PHPMYADMIN with root
  2. Go to Privileges
  3. Create a user or modify the user you want to connect with and set the host parameter to %, which means 'all hosts'.

Open MySQL Port 3306

  1. check: netstat -lpn | grep 3306
  2. /etc/mysql/my.cnf
  3. bind-address -> 0.0.0.0
  4. /etc/init.d/mysql restart
  5. check: netstat -lpn | grep 3306
  6. open port with iptables...

Monday, June 18, 2012

jQuery ToolTip : qTip 2

Download: http://craigsworks.com/projects/qtip2/download/

My config in $(function () { });
  if($('.registration').length) {
    $('.registration input[type=text], .registration input[type=password], .registration select').qtip({
      position: {
        my: 'bottom center', 
        at: 'top center'
      },
      show: {
        event: 'focus'
      },
      hide: {
        event: 'blur'
      },
      style: {
        tip: true,
        classes: 'ui-tooltip-dark'
      }
    });
  }

In the form class...
    // qtip2 i18n tooltips
    $widgetSchema = $this->getWidgetSchema();
    $formFormatter = $widgetSchema->getFormFormatter();
    $addToolTipsFor = array(
        'email', 'email2', 'password', 'password2',
        'billing' => array('name', 'country', 'zip', 'city', 'street', 'phone', 'vat_country', 'vat_number'),
        'shipping' => array('name', 'country', 'zip', 'city', 'street'),
        'contact' => array('name', 'phone')
    );
    foreach($addToolTipsFor as $key => $input) {
      if(is_array($input)) {
        foreach($input as $subinput) {
          if(isset($widgetSchema[$key][$subinput])) {
            $widgetSchema[$key][$subinput]->setAttribute('title', $formFormatter->translate($key.'_'.$subinput.'_tooltip'));
          } else {
            throw new sfException('No widget: '.$key.' '.$subinput);
          }
        }
      } else {
        if(isset($widgetSchema[$input])) {
          $widgetSchema[$input]->setAttribute('title', $formFormatter->translate($input.'_tooltip'));
        } else {
          throw new sfException('No widget: '.$input);
        }
      }
    }
My CSS:
.ui-tooltip, .qtip { font-size: 13px !important; line-height: 20px !important; }

Install APC for PHP in CentOS

yum install pcre-devel gcc httpd-devel php-pear
pecl install apc
64bit: restorecon /usr/lib64/php/modules/apc.so
32bit: restorecon /usr/lib/php/modules/apc.so
echo "extension=apc.so" > /etc/php.d/apc.ini
service httpd restart

Solution: Fatal error: Cannot inherit previously-inherited or override constant LEVEL_TOP from interface Swift_Mime_Message in Symfony

There is a bug in APC. You need install the latest version of APC to solve the problem between Swiftmailer and APC: Install the Latest APC on Debian