Monthly Archives: July 2012

How to close colorbox when clicking on a link?

Colorbox is very cool js plug-in which is used by many developers.

I was creating a facebook app and had situation where i wanted to close Colorbox/popup and open new page which was not suppose to open in Colorbox.

I was searching and found really simple code which can be used in several ways with any php technology stuff.


How to access one server if they are connect with LoadBlancer?

If you are LAMP developer and your server is connected with LoadBlancer now LoadBlancer is big advantage in production to distribute traffic but sometimes it could be trouble for developer as you want to access one server out of two.

Now here is the analogy.
You have 2 servers and web1 and web2. Web1 is main and you are accessing through FTP and adding files then web2 is synced with web1 but while you are developing few files or code you want to access only web1 how to do that ?

Well this is simple, change host file and one config file!
I am using MAC so add these 2 lines in host file and you will be accessing only web1.

edit /etc/hosts
add the lines
at the bottom of the file
edit /etc/resolv.conf
add the line
order hosts, bind
to the top of the file

And you are done!


How to check error log in Apache/LAMP?

First login to your server using ssh

A. ssh
B. Enter proper password

Then switch back to the root and use this command.

Benefit of “-f” option is as you hit your php page in browser terminal will auto refresh errors and you can see most recent errors.

Your Path may be diffrent! I have different sub domains parked in my server. So this is my error log path in LAMP.

Hope it will work for you.


How to get IP address through php code.

Every php coder want to store IP address of user for tracking and other different purpose.

Here is the function which i am using in my code to store ip address in db.

You can use this simple php function in different ways.


Display PHP Errors When Display_errors Is Disabled

When Display_errors is off in php.ini it is hard to see where the bug is!

While you are working in server where display errors are off you can add this code on top of the page and it will show whats going on in your php code.

I prefer to use this code through a function or include file and when you are done you can close or disable.