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. 
 

Friday, May 20, 2011

Import/Export Large MYSQL Databases


When working with MYSQL I often use phpMyAdmin, which is a nice GUI way to manipulate my database. But some operations won't work in phpMyAdmin when the database is too large. In particular, you can't import or export really large databases using phpMyAdmin. So sometimes you need to do things on the command line.
So I thought I'd document some of the command line snippets we use frequently. In the following, replace [USERNAME] with your mysql username, [DBNAME] with your database name, [/path_to_file/DBNAME] with the path and name of the file used for the database dump, and [/path_to_mysql/] with the path to mysql bin (like /Applications/MAMP/Library/bin/).

Copy/Export a Large Database

MYSQL has no 'Copy' function. You create a copy by dumping the database with mysqldump.
To dump the database and gzip it at the same time, use the following. This will prompt you for your password.


mysqldump -u [USERNAME] -p [DBNAME] | gzip > [/path_to_file/DBNAME].sql.gz 

Source Link:

Thursday, May 19, 2011

php codeigniter Eclipse


  1. Download XAMPP and unzip it to your C drive. (If you use Windows Vista, you will need to unzip it one directory down. Common practice is to create a folder title "XAMPP" and unzip there.)
  2. Download CodeIgniter and unzip it to your C drive in a folder named "CodeIgniter".
  3. Open the CodeIgniter folder. There will be a subfolder named "CodeIgniter[version number]". Create a second copy of that subfolder within the CodeIgniter folder (Copy_of_CodeIgniter).
  4. Open Eclipse and set the workspace to any folder other than XAMPP/htdocs (or in Windows Vista, XAMPP/xampp/htdocs).
  5. In eclipse, select File/New/Create New Project/PHP Project
  6. Select the option to "Create from Existing Source", and using the browse button, navigate to C:/CodeIgniter/Copy_of_CodeIgniter". Name the project something meaningful and save.
  7. Switch Eclipse's workspace the htdocs folder withn your XAMPP directory.
  8. From the menu in Eclipse, select File/Import/General/"Import existing projects into workspace".
  9. Browse to C:/CodeIgniter and select Copy_of_CodeIgniter. The project you created should appear in the list of projects and it should be automatically selected for copying.
  10. IMPORTANT! Check the option "copy files into workspace" before finishing the project import.
  11. Now the project will be in htdocs, the default XAMPP web directory. To verify, in your browser typehttp://localhost/PROJECT_NAME and you should see the CodeIgniter welcome page. Your project is ready for editing.
These steps will assist you in setting up the original project. Future projects can be created by starting at step 8.


Download Eclipse:
eclipse-php-helios-SR1-win32.zip
http://www.eclipse.org/pdt/downloads/ 

--------------------------------------------
for integrating codeigniter with eclipse see this video

http://www.youtube.com/watch?v=MzvSA0hq3Ts

very good link--
http://www.associatedcontent.com/article/2378460/setting_up_a_codeigniter_project_in_pg2.html?cat=15


Wednesday, April 27, 2011

Publish facebook page status or wall post automatically


Facebook page is now very popular. Many companies and people create facebook page for their own publicity. Suppose your company has 100 products and they want to maintain 100 facebook pages, then isn’t it very difficult to update status all of the pages manually?

In this article, I’ll show and discuss about 2 facebook api, using that you can easily update your facebook page status or publish wall post on that page automatically
I assume that you know how to set cron from hosting admin panel, I also assume that you have intermediate knowledge of facebook application development and their api usage.

fb_page



At first you’ve to setup a new facebook application. In the application setting look Authentication and in the Authentication setting must tick Facebook Pages

fb_app_setting

Now save the api and secret key either in your database or config file.
Update Status or Publish in Wall of your facebook page:
Source Link: http://thinkdiff.net/facebook/update-facebook-page-status-automatically/

Monday, April 18, 2011

Create Informative Textboxes

http://blog.jbstrickler.com/2010/06/create-informative-textboxes/comment-page-1/Create more informative textboxes by placing descriptive information, or “infotips”, about the textbox directly inside of it. This is particularly useful when it is not always desired to place labels next to textboxes such as in a small log in form. Example, Facebook’s log-in page places text inside its fields rather than using labels. When one of the textboxes receives focus, the text disappears; on blur, if nothing is entered then the infotip is placed back.

or another way is-
onFocus="if(this.value == 'location') {this.value = '';}" 
onBlur="if (this.value == '') {this.value = 'location';}"


Source: http://blog.jbstrickler.com/2010/06/create-informative-textboxes/comment-page-1/


Facebook Log in Snapshot

Sunday, March 27, 2011

Anatomy of a WordPress Plugin & Widget Tutorials


WordPress is well known for its amazing collection of free plugins. There is one for almost every need
you can think of, from backing up your WordPress installation to asking for a cup of coffee
or fighting spam.
But there are times when none of the available plugins seem to quite do the trick you are looking for. To help you in moments like
that, this tutorial will guide you through every step of building a simple, widgetized WordPress plugin with settings.



Link with source code:
http://net.tutsplus.com/tutorials/wordpress/anatomy-of-a-wordpress-plugin/

Monday, March 7, 2011

All Google APIs & Developer Tools In One Plac


Google is providing lots of tools for web designers/developers and almost all of them have their APIs for easier integration with 3rd party services.
If you're a frequent user of these resources and want to reach them easier, Google has a web page specifically for you: Google APIs & Developer Products.
Google APIs & Developer Tools
The page lists all development-related resources of Google with their logos and highlights the ones according to their categories.

First source: http://www.webresourcesdepot.com/all-google-apis-developers-in-one-place/
Second source: http://code.google.com/more/table/

Friday, January 28, 2011

Develop customize facebook application for fan page

For many companies or individual, facebook fan page is an integral part of their social media campaign. They want to build up a large follower in their fan page.
Why?
Because, a company want to inform large number of people about their products. An individual want to make large network. As facebook fan page is a part of facebook, so building a large network is quite easy, but for this you have to make your fan page more dynamic, engaging.

In this article I’ll show you how to develop customize facebook application for fan page, that will be more dynamic and interesting for your fans!


Source: http://thinkdiff.net/facebook/develop-customize-facebook-application-for-fan-page/