Saturday, November 1, 2014

Redirecting non-www to www with .htaccess

If you want to redirect all non-www requests to your site to the www version, all you need to do is add the following code to your .htaccess file:


RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.

RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]



Friday, October 10, 2014

Can't import database through phpmyadmin file size too large

For Upload large size data in using phpmyadmin Do following steps.
Open php.ini file from 
OS                               ->  Location
windows(With Xampp Installation) -> /xampp/php/php.in 
Mac OSX                          -> /private/etc/php.ini
Linux                            -> /etc/php.ini
                                 -> /usr/bin/php5/bin/php.ini
                                 -> /etc/php/php.ini
                                 -> /etc/php5/apache2/php.ini
Update following lines
max_execution_time = 259200
max_input_time = 259200
memory_limit = 1000M
upload_max_filesize = 750M
post_max_size = 750M    
than after restart xampp server or restart all services Now Upload data using import function in phymyadmin. Apply second step if till not upload data.

Saturday, September 27, 2014

Include a JavaScript file in a JavaScript file

function includeJS(incFile)
{
   document.write('<script type="text/javascript" src="'+ incFile+ '"></script>');
}

includeJS('filename.js');

Saturday, September 13, 2014

Add this Setting the URL & Title to Share

Convert utf8-characters and back in PHP

Set meta tag in head as

  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />

use the link http://www.i18nqa.com/debug/utf8-debug.html to replace the symbols character you want.

then use str_replace like
<?php
$content='Kinsa – World’s Smartest Thermometer';
$find = array('“', '’', '…', '—', '–', '‘', 'é', 'Â', '•', 'Ëœ', 'â€'); // en dash
$replace = array('“', '’', '…', '—', '–', '‘', 'é', '', '•', '˜', '”');
echo $content = str_replace($find, $replace, $content);
output Kinsa – World’s Smartest Thermometer
?>

Saturday, July 19, 2014

Get Facebook Likes Count of a page using Graph API

<?php
echo facebooklike('209414452444193');

function facebooklike($page_id){

$likes = 0; //Initialize the count
//Construct a Facebook URL
$json_url ='https://graph.facebook.com/'.$page_id.'';
$json = get_contents($json_url);
$json_output = json_decode($json);

//Extract the likes count from the JSON object
if($json_output->likes){
$likes = $json_output->likes;
}
   return $likes;
 
}

function get_contents($url)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}

?>

Sunday, June 15, 2014

Google OAuth 2 authorization - Error: redirect_uri_mismatch

Go to the console for your project and look under API Access. You should see your client ID & secret there, along with a list of redirect URIs. If the URI you want isn't listed, click edit settings and add the URI to the list.
https://console.developers.google.com