Posts marked with "PHP" in categories

The best method to find client’s IP Address in PHP.

This simple function will help you to find the client’s IP. You could use $_SERVER[‘REMOTE_ADDR’] , but this method will not returns the actual IP address. To get the real IP address use this method. function getUserIpAddr(){     if (!empty($_SERVER[‘HTTP_CLIENT_IP’])){         return $_SERVER[‘HTTP_CLIENT_IP’];     }else if (!empty($_SERVER[‘HTTP_X_FORWARDED_FOR’])){         $ite=explode(‘,’,$_SERVER[‘HTTP_X_FORWARDED_FOR’]); return str_replace(" ",",$ite[0]);     }else{         return $_SERVER[‘REMOTE_ADDR’];... [READ MORE]

Finding Client’s IP address, Country, State, City using api in PHP

If you want to get client’s IP address you will use $_SERVER[‘REMOTE_ADDR’] function in PHP. But you will not get the real IP address of the client. To get the real IP address You can use the method I used. Also With this method you can also find the City, State, Country client’s in. The code is pretty simple. With the help of it was pretty easy. [email protected]_get_contents(‘’);if (empty($response)){throw new InvalidArgumentException("Error contacting Geo-IP-Server"... [READ MORE]

Subins Project Online – Thanks to App Fog

You might have know the project I have been working on. The Subins Project. I have spent a year on this project. My wish was to host this on a site. But I couldn’t afford the hosting charges cause I’m 12 and my dad won’t lend me money. I took a leave because of fever. On that day I was browsing the internet and out of nowhere I saw a post about a site named AppFog.... [READ MORE]

SQL Query in another SQL Query = SQL Subquery

You might have wanted to do a SQL query inside an another SQL query. You can do this using SQL Subquery. It’s simple as ABC. Here’s an example : SELECT * FROM `fdposts` WHERE user IN (SELECT friend FROM `fdfriends` WHERE user=’subins2000′) The above code will select rows in table fdposts where user is the value of friend row in the table fdfriends. As you can see it’s very simple. Here’s another example : SELECT * FROM `posts` WHERE user IN (SELECT name FROM `members` WHERE user=’subins2000′) The above code will select rows in table posts where user is the value of the row name in the table members.... [READ MORE]

How to run/execute SQL Code

If you have installed phpMyAdmin do as below. Go to localhost/phpmyadmin/server_sql.php. Paste the SQL Code in the text box shown in the page and press GO button at the bottom right of the page. If you want to run code in PHP file do as below. Open your PHP file. Add these lines in the file. mysql_query("sql code here"); NOTE – Replace the red line with the SQL code. ... [READ MORE]

phpMyAdmin – A software to manage MySql Database

If you want to manage your MySql table you can use a software called phpMyAdmin. You can install phpMyAdmin in any Operating Systems. This tutorial will help you to install phpMyAdmin in Linux. Requirements PHP You need PHP 5.2.0 or newer, with session support and the Standard PHP Library (SPL) extension. To support uploading of ZIP files, you need the PHP zip extension. For proper support of multibyte strings (eg. UTF-8, which is currently default), you should install mbstring and ctype extensions.... [READ MORE]

Get extension of a file using PHP

This function will allow you to get a file’s extension in PHP. function getExtension($fileName){ $i = strrpos($fileName, "."); if (!$i) { return ""; } $length = strlen($str) - $i; $extens = substr($str, $i+1, $length); return $extens; } For example you need to get a extension of the file photo.jpg. To get the extension type this code in your PHP file. <span style="color: #660000;"<?php</span <span style="color: #660000;"echo</span getExtension<span style="color: #660000;"... [READ MORE]

Upload more than 1 MB file in PHP.

Some may have problem with uploading file more than 1 MB or 2 MB. You can fix this by editing the configuration file of PHP. To fix this follow the steps. Open Root Terminal (Applications - System Tools - Root Terminal). Type  sudo gedit /etc/php5/apache2/php.ini  and press enter key. You will get gedit application with the file. Search for the words post_max_size & upload_max_filesize. If you found the words you will see a = after the word post_max_size & upload_max_filesize.... [READ MORE]

Insert XML Data to MySQL Table Using PHP

This tutorial will help you to insert XML file’s contents to a MySQL Database table using php. Note- If you can’t open PHP files in browser in Ubuntu Linux See the Tutorial : This is the XML data we are going to insert in to our MySQL Table. <span style="font-family: inherit;"<items></span <span style="font-family: inherit;" <item></span <span style="font-family: inherit;" <title>Google</title></span <span style="font-family: inherit;" <url></url></span <span style="font-family: inherit;" </item></span <span style="... [READ MORE]

Hide or show a div using data sent to a php file

This tutorial will help you to send data to a php file to hide a div ie sending a string to a php file to hide a div.Follow these steps. 1 : Open the php file which contains the div to hide.       Paste this code above the  tag <blockquote class="tr_bq"> <p> <b><style type="text/css"></b><b><span style="font-family: Times, 'Times New Roman', serif;">#<?php echo $_GET[&#8216;div&#8217;]; ?>{</span></b><b><span style="font-family: Times, 'Times New Roman', serif;"><span style="color: red;">display:none;</span></span></b><b><span style="font-family: Times, 'Times New Roman', serif;">}</span></b><b><span style="font-family: Times, 'Times New Roman', serif;"></style></span></b> </p> </blockquote>... [READ MORE]


Email :

Subscribe To All


If you found something helpful, please consider a donation to support this site and projects :)





This blog was once on WordPress. Now a static site. See source code on