January 30, 2011 at 8:05 pm
· Filed under PHP
There are many sites out there which tell you your own IP address. But all of them show you some ads, take some time to load and consume bandwidth (not a problem now a days). I decided to create one for my own use due to this. I thought to share the code and URL with you.
PHP's $_SERVER ($_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server) came to my help. I used REMOTE_ADDR, because I don't need the IP behind the proxy at the moment. Here is the code to get the IP address
echo "IP: ". $_SERVER['REMOTE_ADDR'];
Here is the URL (http://ip.mwasif.com) to know your IP address.
REMOTE_ADDR: The IP address from which the user is viewing the current page.
HTTP_X_FORWARDED_FOR: The IP address of the user behind proxy. Becareful while using this, sometimes it may return user's LAN address.
Permalink
January 16, 2011 at 1:51 am
· Filed under .htaccess, Apache, PHP
You can remove PHPSESSID from URL by changing session.use_trans_sid value in php.ini, .htaccess (Apache) or in PHP code.
In php.ini set the value of session.use_trans_sid to 0
session.use_trans_sid = 0
In .htaccess
php_value session.use_trans_sid 0
In PHP code set the use_trans_sid value to false like below
ini_set('session.use_trans_sid', false);
Permalink
August 8, 2008 at 11:45 pm
· Filed under News, PHP
The last release of PHP 4 is now available for download on 7th of August 2008. PHP 4 has been serving the web sites since 2000.
Permalink
March 15, 2008 at 12:10 am
· Filed under .htaccess, Apache, PHP
There are different options to increase file upload limit in PHP. First is changing PHP configuration file (php.ini) and restarting webserver or overwriting the php.ini value in .htacces (this option is available if you are running Apache).
There are 2 directives which affect upload limit i.e. upload_max_filesize and post_max_size.
Now we look at the first method. First you have to find out where the php.ini is. To find out the location, make a .php file containing only this code and place it in your webroot and point your browser to this file.
< ?php phpinfo(); ?>
In the page output you can find Configuration File Path. Open this file and change the values for upload_max_filesize and post_max_size according to your requirement e.g. to set 10MB upload limit, the values will be
upload_max_filesize = 10M
post_max_size = 10M
Read the rest of this entry »
Permalink
July 18, 2007 at 11:33 pm
· Filed under MySQL, PHP
People have different opinions on saving images in database. Some says, "Why bother database if we can handle this by saving images to disk". I am agree with this;).
Most of the requirements can be fulfilled by saving the images to disk. This reduces the unnecessary load on MySQL.
Here is the small code to save the image in MySQL with the help of PHP.
Read the rest of this entry »
Permalink
July 1, 2007 at 4:05 am
· Filed under MySQL, PHP
This is a very simple example to download data in csv format using PHP and MySQL. I have used a table with two columns i.e. id and name.
The main point to download file is a proper use of header(). It has said many times in many places but I repeat here, "Make sure there must not be any sort of output (including whitespaces) before header()". We can also set a default file name for the file.
Here is the PHP code
Read the rest of this entry »
Permalink
June 16, 2007 at 6:49 pm
· Filed under .htaccess, Apache, PHP
It is strongly recommended that you do not turn on the register_globals. But if you still want to turn on register_globals then follow these steps
Make a .php file containing only this code
< ?php phpinfo(); ?>
And upload this file to your new server and open in the browser. In the page output find the value for 'register_globals'. If it is off, then you can solve this problem in the following ways
Read the rest of this entry »
Permalink