Export MySql Database in Linux Command Line

I will show you how to export MySql Database in Linux Command Line

mysqldump -u root databasename –ignore-table=databasename.accesslogs  > filename.sql

Zip it using 7zip
7za a -t7z filename.7z filename.sql

The –ignore-table is pretty straightforward, it simply means do not include this table when exporting.

Using JSONP in jQuery Ajax

PHP Server Side

    $callback = $_GET['callback'];
    $result = array();
    $result[0]['id'] = '111';
    $result[0]['title'] = 'Event1';
    $result[0]['start'] = '2014-05-10';
    $result[0]['end'] = '2014-05-12';

    $result[1]['id'] = '112';
    $result[1]['title'] = 'Event2';
    $result[1]['start'] = '2014-05-10';
    $result[1]['end'] = '2014-05-12';
    $jsdata = ($callback.'('.json_encode($result).');'); 
    echo $jsdata;

When using jsonp, it is very important to wrap the data with the callback. Try to look at the $jsdata variable, it is being wrapped by the $callback variable. That’s just how jQuery Ajax works. If you won’t wrap it with that one, you’ll get an error in your console.

Front End (Ajax and jQuery)

  jQuery.ajax({
    type:"GET",
    dataType:'jsonp',
    url: "http://mysite.com",
    error: function(xhr, status, error) {
      console.log(xhr);
      console.log(status);
      console.log(error);
    },
    success:function(data){
      console.log(data);
    }
  });

JSONP is important when trying to call an external domain in your ajax. It’s like when you’re in your http://localhost/myproject/index.php , then calling a domain at http://facebook.com/apiv1/something using ajax.

Yii Fixing failed to open stream: No such file or directory

I’ll show you how to fix Yii failed to open stream: No such file or directory when integrating an extension or a 3rd party application.

Yii::import('ext.aweber.*');
/*Disable Yii's autoloading, and do a require once*/
spl_autoload_unregister(array('YiiBase', 'autoload'));
require_once('aweber_api.php');

/*Add some of your codes...*?
/*Then just enable Yii's autoload functionality to make things back to normal again*/
spl_autoload_register(array('YiiBase', 'autoload')); // Enable Yii autoloader

Those files are just examples. I noticed this error when I started using Aweber API, then realized this might help others too when integrating an extension or a 3rd party library.

Have fun! :)

Creating SEO friendly URL using htaccess

Creating SEO friendly URL requires a knowledge on how htaccess works. Not just that, you should also be familiar with Regular Expressions but I won’t cover that one in this post though since we’ll be focusing on putting those in htaccess. Now, let’s get our hands dirty.

For example:
http://mysite.com/profile.php?username=JuanDelaCruz

If you wanted that one to become
http://mysite.com/user/JuanDelaCruz/

This is what you’re going to do:

#RewriteEngine On
#RewriteCond %{REQUEST_FILENAME} !-d 
#RewriteCond %{REQUEST_FILENAME}\.php -f 
#RewriteRule ^(.*)$ $1.php

# Use the following rule if you want to make the page like a directory
RewriteCond %{REQUEST_URI} !^/user/profile.php
RewriteRule ^user/(.*[^/])$ user/$1/ [R=301,L]

# The following rewrite the other way round:
RewriteCond %{REQUEST_URI} ^/profile.php
RewriteCond %{THE_REQUEST} ^(GET|POST|HEAD|TRACE)\ /profile.php
RewriteCond %{QUERY_STRING} id=([^&]+)
RewriteRule ^profile.php$ user/%1?

There are comments, so hope you can understand it from there.
Hope this helps someone! Have a Happy Coding! :)