Archive for the ‘PHP’ category

Remove index.php on CodeIgniter using .htacces

June 7th, 2012

By default CodeIgniter framework url will includes index.php, it’s pretty easy to remove index.php from your url to work with CodeIgniter using .htaccess.

I assume that your web server already enable mod_rewrite module (mostly any web hosting already enable it). Create new file .htaccess in your CodeIgniter code root (same level with index.php) as like this.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

Save it, and violaa… your CodeIgniter has pretty URL.

How to disable wordpress toolbar for all users

April 1st, 2012

New wordpress engine has a feature called toolbar and its shown in the top of our blog page. What ridiculous is there’s no built-in function to disable this toolbar for being shown to all our users, which mean the users have to manually disable it in their profile page. Fortunately we can use this snippet to disable this toolbar.

Add this snippet to your theme functions.php file

function my_function_admin_bar(){
    return false;
}
add_filter( 'show_admin_bar' , 'my_function_admin_bar');

How to post JSON data from Android to PHP Codeigniter

March 30th, 2012

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. This article explains how to client-server web service communication using Android and PHP, we will use JSON as the data.

We will build a simple calculator web service that has features such as add and multiply.

apikey represent key to access the webservice, the server will reject the request if the key is invalid, in this article we use “mykey123″
command represent what command request we want to use, in this article we use “add” or “multiply”
a and b represent input value we want to calculate » Read more: How to post JSON data from Android to PHP Codeigniter

What people search:

Enable PHP display_error on MAMP 2.0.5

March 22nd, 2012

By default display_error on MAMP 2.0.5 is off, in my opinion it would be useful for me to turn it on for development phase of my application. This is how to enable display_error

  1. Find MAMP directory under Application Directory
  2. Go to MAMP\bin\php\
  3. Open PHP folder that you are using
  4. Then open \bin\conf\php.ini under your PHP folder
  5. Find error_reporting line, and make sure as “error_reporting = E_ALL
  6. Find display_errors = Off, and change it to display_errors = On
  7. Save then restart your MAMP
  8. Done

Run web.py as a service in linux

March 22nd, 2012

web.py is a web framework for Python that is as simple as it is powerful. web.py is in the public domain; you can use it for whatever purpose with absolutely no restrictions.

I was building a simple application with this library and need this run as a background service.

python /opt/server.py 8080 2>/dev/null &

PHP Date Timezone error ( date_default_timezone_set )

December 9th, 2011

I was experiencing an error regarding date() function on PHP 5 with error message like this :
Message: 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/Jakarta' for 'WIT/7.0/no DST' instead

For quick fix in PHP5, add this line

date_default_timezone_set("Asia/Jakarta")

Access CPanel behind company proxy firewall

December 2nd, 2010

I was having problem accessing my web server from my company, my company network only open port 80 for internet access. So it would be impossible if someone trying to do to access CPanel behind this firewall.

But there’s a way for us to access CPanel via port 80 on our server, there’s no change at all both side our network or server. To access CPanel behind company firewall we can go to http://cpanel.domain.com, replace the domain.com with your own domain. For example http://cpanel.leoganda.net

By using this technique we are bypassing the port on our server, and accessing the port 80 over CPanel. So we gain access.

Auto Post Using Javascript

December 5th, 2009

Hi there, a few weeks ago I was doing research about auto post from webpage to paypal payment page. The basic idea is the visitor fill the form, then when the visitor submit the form we will store visitor data input to database. Once data stored in database the page will be automatically redirected to paypal website. It’s pretty easy, we will use JavaScript to do auto post. I wanna make this article as simple as possible, I just wanna show how to do auto post with Javascript. » Read more: Auto Post Using Javascript

What people search:

Solving Zend Framework error “An Error Has Occurred A project profile was not found”

October 15th, 2009

Hi there, I had an error “An Error Has Occurred A project profile was not found” on Zend framework command line when I tried to generate an action for my project. I’m using Windows XP and for the web server I’m using XAMPP. The “An Error Has Occurred A project profile was not found” happened because we have wrong include path in our php.ini.

Open your php.ini and find the include_path line, insert your zend framework library path into the line before the PEAR path.

include_path = ".;E:\xampp\htdocs\ZendFramework\library;E:\xampp\php\PEAR"

Save the file and restart your Apache. Good luck :)

What people search:

How to enable XAMPP SSL socket transport

July 26th, 2009

Hi today I have an experiment with GData in Zend Framework PHP , and found an error that my XAMPP prevent SSL socket transport and return this error.

Fatal error: Uncaught exception 'Zend_Gdata_App_HttpException' with message 'Unable to Connect to ssl://www.google.com:443. Error #24: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?' » Read more: How to enable XAMPP SSL socket transport

What people search: