To get the real IP address use this method.
function getUserIpAddr(){
... [READ MORE]
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’];
}
} $cip=getUserIpAddr();
Finding Client’s IP address, Country, State, City using NetIP.de api 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 NetIP.de it was pretty easy.
$response=@file_get_contents(‘http://www.netip.de’);if (empty($response)){throw new InvalidArgumentException("Error contacting Geo-IP-Server");}$patterns=array();$patterns["state"] = ‘#State/Region: (.*?)
... [READ MORE]
;$patterns["IP"] = ‘#IP: (.*?) #i’;$patterns["country"] = ‘#Country: (.*?) #i’;$patterns["city"] = ‘#City: (.*?)
$pattern){$ipInfo[$key] = preg_match($pattern,$response,$value) && !empty($value[1]) ? $value[1] : ‘not found’;} $uct=$ipInfo["state"];$uip=$ipInfo["IP"];$uci=$ipInfo["city"];$ipInfo=explode(‘-‘,$ipInfo["country"]);$ucs=$ipInfo[0];$uco=$ipInfo[1];
Subins Project Online – Thanks to App Fog
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. The post said that AppFog gives free hosting on their servers under their domain name. So quickly I went to AppFog and signed up. It was pretty easy. I created my site in the domain subins.hp.af.cm.
... [READ MORE]SQL Query in another SQL Query = SQL Subquery
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′)
... [READ MORE]
How to run/execute SQL Code
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.
phpMyAdmin – A software to manage MySql Database
<h2 id="require" style="font-family: sans-serif; max-width: 70em;">
Requirements
</h2>
<ul style="font-family: sans-serif; margin: 1em; max-width: 70em;">
<li style="margin-top: 0.5em;">
<b>PHP</b> <ul style="margin: 1em 1em 0px; max-width: 70em;">
<li style="margin-top: 0.5em;">
You need PHP 5.2.0 or newer, with <tt>session</tt> support and the Standard PHP Library (SPL) extension.
</li>
<li style="margin-top: 0.5em;">
To support uploading of ZIP files, you need the PHP <tt>zip</tt> extension.
</li>
<li style="margin-top: 0.5em;">
For proper support of multibyte strings (eg. UTF-8, which is currently default), you should install mbstring and ctype extensions.
</li>
<li style="margin-top: 0.5em;">
You need GD2 support in PHP to display inline thumbnails of JPEGs ("image/jpeg: inline") with their original aspect ratio
</li>
<li style="margin-top: 0.5em;">
When using the "cookie" authentication method, the <tt>mcrypt</tt> extension is strongly suggested for most users and is <b>required</b> for 64–bit machines. Not using mcrypt will cause phpMyAdmin to load pages significantly slower.
</li>
<li style="margin-top: 0.5em;">
To support upload progress bars.
</li>
</ul>
</li>
<li style="margin-top: 0.5em;">
<b>MySQL</b> 5.0 or newer (details);
</li>
<li style="margin-top: 0.5em;">
<b>Web browser</b> with cookies enabled.
</li>
</ul>
sudo apt-get install phpmyadmin
... [READ MORE]
Get extension of a file using 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;">(</span>'<b><span style="color: #e06666;">photo.jpg</span></b>'<span style="color: #660000;">);</span> <span style="color: #660000;">?></span>
The above code will print out "jpg".
... [READ MORE]Upload more than 1 MB file in PHP.
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 php.in 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.
Change the number as you want (Default will be 1M or 2M).
After editing save the file and restart Apache Web Server by opening Root Terminal and pasting this code
Insert XML Data to MySQL Table Using PHP
<pre class="prettyprint"><code><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>google.com</url></span> <span style=“font-family: inherit;"> </item></span> <span style=“font-family: inherit;"> <item></span> <span style=“font-family: inherit;"> <title>Google Accounts</title></span> <span style=“font-family: inherit;"> <url>accounts.google.com</url></span> <span style=“font-family: inherit;"> </item></span> <span style=“font-family: inherit;"></items> </span>
... [READ MORE]Hide or show a div using data sent to a php file
<blockquote class="tr_bq">
<p>
<b><style type="text/css"></b><b><span style="font-family: Times, 'Times New Roman', serif;">#<?php echo $_GET[‘div’]; ?>{</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>
If you want to show a div change the line "display:none;" to "display:block;"
... [READ MORE]