Sunday, December 18, 2011

How to get Latitude/Longitude from an address (or Geocoding ) using PHP

$geocode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address=573/1,+Jangli+Maharaj+Road,+Deccan+Gymkhana,+Pune,+Maharashtra,+India&sensor=false');

$output= json_decode($geocode);

$lat = $output->results[0]->geometry->location->lat;
$long = $output->results[0]->geometry->location->lng;
 
Source: http://amiworks.co.in/talk/how-to-get-latitudelongitude-from-an-address-or-geocoding-using-php/ 

Tuesday, September 20, 2011

HTML 5 Geolocation with Safari on the iPhone 3.0 OS, Firefox 3.5 and Chrome


HTML 5 Geolocation 

Your address: Nehru Park Rd, Indore, Madhya Pradesh, India
This is a quick demonstration of the proposed HTML 5 standard for a Geolocation API.
If your browser does not support geolocation, but you do have a GPS unit in your browsing device, you can try the newest version of Firefox or a geolocation addon for older versions of Firefox. Both will fallback on other options for geolocation (IP address, WiFi networks in your area) if you do not have a GPS device installed. Google Chrome is also an HTML 5 geolocation aware browser.
The first step is to retrieve the Javascript object with 'navigator.geolocation':
if (navigator.geolocation) 
{
 navigator.geolocation.getCurrentPosition( 
 
  function (position) {  
 
  // Did we get the position correctly?
  // alert (position.coords.latitude);
 
  // To see everything available in the position.coords array:
  // for (key in position.coords) {alert(key)}
 
  mapServiceProvider(position.coords.latitude,position.coords.longitude);
 
  }, 
  // next function is the error callback
  function (error)
  {
   switch(error.code) 
   {
    case error.TIMEOUT:
     alert ('Timeout');
     break;
    case error.POSITION_UNAVAILABLE:
     alert ('Position unavailable');
     break;
    case error.PERMISSION_DENIED:
     alert ('Permission denied');
     break;
    case error.UNKNOWN_ERROR:
     alert ('Unknown error');
     break;
   }
  }
  );
 }
}
else // finish the error checking if the client is not compliant with the spec
Next, I've abstracted the mapping function so we can easily change providers if necessary:
function mapServiceProvider(latitude,longitude)
{
 // querystring function from prettycode.org: 
 // http://prettycode.org/2009/04/21/javascript-query-string/
 
 if (window.location.querystring['serviceProvider']=='Yahoo')
 {
  mapThisYahoo(latitude,longitude);
 }
 else
 {
  mapThisGoogle(latitude,longitude);
 }
}
Finally, send the coordinates to the mapping system, plot the client's location, and reverse geocode the longitude and latitude to give us back a human readable address:
// be sure to include the script to initialize Google or Yahoo! Maps
 
function mapThisGoogle(latitude,longitude)
{
 var mapCenter = new GLatLng(latitude,longitude);
 map = new GMap2(document.getElementById("map"));
 map.setCenter(mapCenter, 15);
 map.addOverlay(new GMarker(mapCenter));
 
 // Start up a new reverse geocoder for addresses?
 geocoder = new GClientGeocoder();
 geocoder.getLocations(latitude+','+longitude, addAddressToMap);
}
I believe this HTML 5 geolocation demo fixes a few minor glitches in the previous one at maxheapsize. Rather than feeding it through an input text box, like on maxheapsize, I've found it more reliable to send the coords in directly to the Google Geocoder. You'll find on the maxheapsize example that if you refresh the page on your iPhone, the locating function will fail. Not so with this example here.
I also think that adding a short (500 ms) delay to the map initialization gives more accurate geolocation results on the iPhone with Safari, but I may be mistaken.

source link:
http://merged.ca/iphone/html5-geolocation
http://blog.josemanuelperez.es/2010/07/google-maps-geolocation-directions-specific-destination/

Sunday, August 21, 2011


First lets look at what is mySQL database?


MySQL is a relational database management system (RDBMS) which has more than 11 million installations. The program runs as a server providing multi-user access to a number of databases. MySQL is owned and sponsored by a single for-profit firm, the Swedish company MySQL AB, now a subsidiary of Sun Microsystems, which holds the copyright to most of the codebase. The project's source code is available under terms of the GNU General Public License, as well as under a variety of proprietary agreements.


Why use import or export of sql dump file (scenario)?


I have two MySQL databases located on a server somewhere. I connect via secure shell. I don't know all of the details about the configuration of this particular server but it obviously has MySQL installed/configured properly and you can assume that any other 'very likely' items would also be resident. I need to completley copy one database into the other (one is currently quite large, the second is empty).

And the easiest way to do this is use sql export to dump file and sql import of dump file to mySQL database.

How to create mySQL dump file (export database to sql file)?


The easiest way to export is use next syntax in command prompt (cmd):
mysqldump -u USER -p PASSWORD DATABASE > filename.sql

For example we have database with next parameters:

database username baseu01
database password h4z56s3
database name database01
sql export file name export.sql

Appropriate command line for export is:
mysqldump -u baseu01 -p h4z56s3 database01 > filename.sql

After executing export command you will have file "export.sql" in your folder.

Example how sql export dump file looks like:
-- phpMyAdmin SQL Dump
-- version 2.9.0.2
-- http://www.phpmyadmin.net
-- 
-- Host: localhost
-- Generation Time: Feb 26, 2007 at 07:14 AM
-- Server version: 4.1.21
-- PHP Version: 4.4.2
-- 
-- Database: `optimumd_search`

How to import sql dump file to mySQL database?

The scenario: server crashes and you got mysql dump file stored on your hard drive. First you install mySQL database - then create database, database user and database password and then use next command line: mysql -u username -p password database_name < filename.sql If we use the same example as we used for export command line for export is: mysql -u baseu01 -p h4z56s3 database01 < export.sql

Advanced options for exporting or importing a database

How to Export A MySQL Database Structures Only

If you no longer need the data inside the database’s tables (unlikely), simply add –no-data switch to export only the tables’ structures. For example, the syntax is: mysqldump -u username -ppassword –no-data database_name > dump.sql

How to Backup Only Data of a MySQL Database

If you only want the data to be backed up, use –no-create-info option. With this setting, the dump will not re-create the database, tables, fields, and other structures when importing. Use this only if you pretty sure that you have a duplicate databases with same structure, where you only need to refresh the data. Syntax: mysqldump -u username -ppassword –no-create-info database_name > dump.sql

How to Dump Several MySQL Databases into Text File

–databases option allows you to specify more than 1 database. Example syntax: mysqldump -u username -ppassword –databases db_name1 [db_name2 ...] > dump.sql

How to Dump All Databases in MySQL Server

To dump all databases, use the –all-databases option, and no databases’ name need to be specified anymore. mysqldump -u username -ppassword –all-databases > dump.sql

How to Online Backup InnoDB Tables

Backup the database inevitable cause MySQL server unavailable to applications because when exporting, all tables acquired a global read lock using FLUSH TABLES WITH READ LOCK at the beginning of the dump until finish. So although READ statements can proceed, all INSERT, UPDATE and DELETE statements will have to queue due to locked tables, as if MySQL is down or stalled. If you’re using InnoDB, –single-transaction is the way to minimize this locking time duration to almost non-existent as if performing an online backup. It works by reading the binary log coordinates as soon as the lock has been acquired, and lock is then immediately released. Syntax: mysqldump -u username -ppassword –all-databases –single-transaction > dump.sql

mysql database import-export usage and linking to us

This tutorial can be used with windows server 2003, windows server 2000, windows XP and windows XP proffessional or even unix wervers - as long as mySQL database is installed on your computer. If you find this tutorial to be usefull please add link to it import-sql-dump-file-to-mysql-database so other people will also find this tutorial page.
Source Link:http://www.velikan.net/import-sql-dump-file-to-mysql-database/

Saturday, August 6, 2011

Retrieve Your Gmail Emails Using PHP and IMAP


Grabbing emails from your Gmail account using PHP is probably easier than you think. Armed with PHP and its IMAP extension, you can retrieve emails from your Gmail account in no time! Just for fun, I'll be using the MooTools Fx.Accordion plugin to display each email.

Source Link: http://davidwalsh.name/gmail-php-imap
Another Source Link: http://garrettstjohn.com/entry/reading-emails-with-php/

Tuesday, June 7, 2011

Create a Lightbox effect only with CSS – no javascript needed

You may call it Lightbox, or Greybox, or Thickbox, but it’s always the same effect.
When you are on a page, and click on a photo or trig some event, a Lightbox is an effect that fades the pagein the background to show you new content in the foreground.
I mean this effect
Lightbox
In the upper example, when clicking on a photo the site fades to black and shows the photo, in the lower one when clicking on “login” the site fades to white and shows the login form.
There are tons of Lightbox scripts in the web, each one with its unique features and limitations, but all require massive use of Javascript or the installation of javascript frameworks.
In some cases, there are “lightweight” versions with “only” 40KB of Javascript.
This example does not want to compete with those scripts, but if you are looking for a simple, 100% CSS, 0% javascript lightbox, this may help you.

Source: http://www.emanueleferonato.com/2007/08/22/create-a-lightbox-effect-only-with-css-no-javascript-needed/

Saturday, June 4, 2011

IP Address Geolocation XML API

The API returns the location of an IP address (country, region, city, zipcode, latitude, longitude) and the associated timezone in XML format. You can find below code samples with PHP, Javascript, Ruby, Python and ASP.
Usage
For city precision, do a query with the following API (if you omit the IP parameter it will check with your own IP) :
http://api.ipinfodb.com/v3/ip-city/?key=&ip=74.125.45.100
For country precision (faster), do a query with the following API :
http://api.ipinfodb.com/v3/ip-country/?key=&ip=74.125.45.100
If you don’t have an API key yet, just go to here and register for your free API key. You will need this API key to be able to use our newer APIs.