Wednesday, February 27, 2013

Facebook Graph Api Example Script by Php

All the Facebook Graph Api Example Code using php.This bundle of script contain below facebook script .
  • Facebook  Activity Feed
  • Facebook Add Friends
  • Facebook Comments
  • Facebook Like Button
  • Facebook Like Box
  • Facepile
  • Facebook Recommendation
  • Facebook Status update
  • Live Stream
Download Facebook Script
Facebook Activity Feed
Facebook Add Friends
Facebook Comments
Facebook Like Button
Facebook Like Box
Facepile
Facebook Recommendation
Facebook Status update
Live Stream

Facebook Like Button Using Php Script

Facebook Like button lets users share pages from your site back to their Facebook profile with one click.
Its easy and very simple.But First You have Create Facebook Application because without any application ID this Task is not done.

Step for Facebook Update State :

1) Create Facebook class file :( Facebook_plugins_class.php ) 

in this add application id and language code and set facebook sdk on and then create one function
display_status_update() and apply its parameter.

function get_like_box($criteria=array()) {
        $url = $criteria['url'];
        $width = $criteria['width'];
        $height = $criteria['height'];
        $colorscheme = $criteria['colorscheme'];
        $header = $criteria['header'];
        $showfaces = $criteria['showfaces'];
        $stream = $criteria['stream'];
       
        if($url=='') $url = '';
        if($width=='') $width = '292';
        if($height=='') $height = '427';
        if($colorscheme=='') $colorscheme = 'light'; //light, dark
        if($header=='') $header = 'true';
        if($show_faces=='') $show_faces = 'true';
        if($stream=='') $stream = 'true';
       
        $content = '<iframe src="http://www.facebook.com/plugins/likebox.php?href='.$url.'&amp;width='.$width.'&amp;colorscheme='.$colorscheme.'&amp;show_faces='.$show_faces.'&amp;stream='.$stream.'&amp;header='.$header.'&amp;height='.$height.'" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:'.$width.'px; height:'.$height.'px;" allowTransparency="true"></iframe>';
       
        return $content;
    }


2) Create Facebook like file :(fb_like.php )

<?php
    include_once('Facebook_plugins_class.php');

    $f1 = new Facebook_plugins_class();
    $display = $f1->get_like_button(array('url'=>'https://www.facebook.com/profile.php?id=100001462485647'));
    echo '<div style="padding-bottom:8px;">Available on tutjunction: <a href="https://www.facebook.com/profile.php?id=100001462485647" target="_blank">Facebook WPress Viral tool for WordPress</a></div>';
    echo ''.$display.'<br><br>';
    ?>
</div>
<h3>Facebook Like box</h3>
<div>
    <?php
    $f1 = new Facebook_plugins_class();
    $display = $f1->get_like_box(array('url'=>'https://www.facebook.com/pages/Hellomeed/195450280529871'));
    echo $display;
    ?> 


 

Facebook Activity Feed Using Php

Facebook Activity Feed plugin shows users what their friends are doing on your site through likes and comments.

Step for Facebook Update State :

1) Create Facebook class file :( Facebook_plugins_class.php ) 

in this add application id and language code and set facebook sdk on and then create one function
get_activity_feed() and apply its parameter.

class Facebook_plugins_class
{
    var $app_id = '115461585200271';
    var $lang = 'en_US'; //en_US, fr_FR, es_LA, ko_KR, ja_JP, de_DE
    var $fb_sdk = '1';
   
    function Facebook_plugins_class($criteria=array()) {
        static $witness;
        if($criteria['app_id']!='') $this->app_id = $criteria['app_id'];
        if($criteria['lang']!='') $this->lang = $criteria['lang'];
        if($criteria['fb_sdk']!='') $this->fb_sdk = $criteria['fb_sdk'];
       
        if($witness=='') {
            if($this->fb_sdk=='1') echo '<div id="fb-root"></div><script src="http://connect.facebook.net/'.$this->lang.'/all.js#appId='.$this->app_id.'&amp;xfbml=1"></script>';
            $witness=1;
        }
    }

function get_activity_feed($criteria=array()) {
        $domain = $criteria['domain'];
        $width = $criteria['width'];
        $height = $criteria['height'];
        $colorscheme = $criteria['colorscheme'];
        $header = $criteria['header'];
        $recommendations = $criteria['recommendations'];
        $border_color = $criteria['border_color'];
        $font = $criteria['font'];
       
        if($domain=='') $domain = '';
        if($width=='') $width = '300';
        if($height=='') $height = '300';
        if($colorscheme=='') $colorscheme = 'light'; //light, dark
        if($header=='') $header = 'true';
        if($recommendations=='') $recommendations = 'false';
        if($border_color=='') $border_color = '';
        if($font=='') $font = ''; //'arial', 'lucida grande', 'segoe ui', 'tahoma', 'trebuchet ms', 'verdana'
       
        $content = '<iframe src="http://www.facebook.com/plugins/activity.php?site='.$domain.'&amp;width='.$width.'&amp;height='.$height.'&amp;header='.$header.'&amp;colorscheme='.$colorscheme.'&amp;font='.$font.'&amp;border_color='.$border_color.'&amp;recommendations='.$recommendations.'" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:'.$width.'px; height:'.$height.'px;" allowTransparency="true"></iframe>';
       
        return $content;
    }



2) call this function activity file ( activity.php )

<?php
include_once('Facebook_plugins_class.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PhpWeb Blog</title>
</head>
<body>
<h3>Facebook Activity Feed</h3>
<div>
    <?php
    $f1 = new Facebook_plugins_class();
    $display = $f1->get_activity_feed(array('domain'=>'themeforest.net', 'width'=>'460'));
    echo $display;
    ?>
</div>
</body>
</html>


 

Facebook Status Update Using Php Script

Facebook Status Update using Facebook Graph Api and Php Script.Its easy and very simple.But First You have Create Facebook Application because without any application ID this Task is not done.

Step for Facebook Update State :

1) Create Facebook class file :( Facebook_plugins_class.php ) 

in this add application id and language code and set facebook sdk on and then create one function
display_status_update() and apply its parameter.

function display_status_update($criteria=array()) {
        $app_id = $criteria['app_id'];
        $title = $criteria['title'];
        $message = $criteria['message'];
        $name = $criteria['name'];
        $link = $criteria['link'];
        $picture = $criteria['picture'];
        $caption = $criteria['caption'];
        $description = $criteria['description'];
       
        if($app_id=='') $app_id = $this->app_id;
        if($title=='') $title = '';
        if($message=='') $message = '';
        if($name=='') $name = '';
        if($link=='') $link = '';
        if($picture=='') $picture = '';
        if($caption=='') $caption = '';
        if($description=='') $description = '';
        $random = rand(9999,9999999).rand(9999,9999999).rand(9999,9999999);     
        $js ='
        <script>
        function fc_post_fb_update_'.$random.'() {
            FB.ui({
                method: \'feed\',
                message: \''.$message.'\',
                name: \''.$name.'\',
                 link: \''.$link.'\',
                 picture: \''.$picture.'\',
                 caption: \''.$caption.'\',
                 description: \''.$description.'\',
            });
        }
        </script>';
        $content = '<a href="javascript:" onclick="fc_post_fb_update_'.$random.'()">'.$title.'</a>';
        return $content.$js;
    }


1) Create Facebook Status Update file :(fb_update.php ) 
in this file include the above class and call this function.

<?php
include_once('Facebook_plugins_class.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>php Web tutorials</title>
</head>
<body>
<h3>Facebook status update dialog</h3>
<div>
    <?php
    $f1 = new Facebook_plugins_class();
    $display = $f1->display_status_update(array('title'=>'Click here to update your Facebook status'));
    echo '1. Standard:<br>';
    echo '<b>'.$display.'</b>';
   
    echo '<br>';
   
    $display = $f1->display_status_update(array('title'=>'Click here to update your Facebook status', 'link'=>'http://tutjunction.com'));
    echo '2. Update status + share an attached link:<br>';
    echo '<b>'.$display.'</b>';
   
    echo '<br><br>';
   
    $display = $f1->display_status_update(array('title'=>'Click here to update your Facebook status', 'link'=>'http://tutjunction.com', 'description'=>'Have a look on the services offered by this company!', 'picture'=>'http://tutjunction.com/wp-content/upload/'));
    echo '3. Update status + share an attached link + description + custom picture attached:<br>';
    echo '<b>'.$display.'</b>';
   
    echo '<br><br>';
    echo '<b>Tip:</b><br>Our Facebook status function doesn\'t require your users to authorize your application before they can post to their wall. They can do it right away! Just try it yourself with one of the 3 examples above.';  ?>
</div>
</body>
</html>



Tuesday, February 26, 2013

Create Dynamic Html2PDF by Dompdf Library

dompdf is an HTML to PDF converter. At its heart, dompdf is a compliant HTML layout and rendering engine written in PHP. It is a style-driven renderer: it will download and read external stylesheets, inline style tags, and the style attributes of individual HTML elements. It also supports most presentational HTML attributes.Easy PDF generation with PHP.

Features

  • handles most CSS 2.1 and a few CSS3 properties, including @import, @media & @page rules
  • supports most presentational HTML 4.0 attributes
  • supports external stylesheets, either local or through http/ftp (via fopen-wrappers)
  • supports complex tables, including row & column spans, separate & collapsed border models, individual cell styling
  • image support (gif, png (8, 24 and 32 bit with alpha channel), bmp & jpeg)
  • no dependencies on external PDF libraries, thanks to the R&OS PDF class
  • inline PHP support  
Example :

<?php
require_once("dompdf_config.inc.php");
$html =
    '<html><body>'.
    '<p>Hello World!</p>'.
    '</body></html>';

$dompdf = new DOMPDF();
$dompdf->load_html($html);

$dompdf->render();
$dompdf->stream("hello_world.pdf");
?>

Click For Demo  Click For Download

Monday, February 25, 2013

Create Ms Word File By Php Script

A Fast Way Two Generate Microsoft Word file by php code.Its very easy and nice Script to Generate the dynamic word file by php.Using This Script you have Generate or Download word report by php.

Example Code :

$fp = fopen("amit.doc", 'w+');
$str = "paypal and facebook and google and linkdin hello";
 fwrite($fp, $str);
 fclose($fp);

Thursday, February 21, 2013

Copy Rename and Delete File By Php Script

Hey Friends Today ,
We Learn About How to Copy,Rename and Delete File Uisng Php Code.
For performing this action use php function like.
For copy file user Copy(),for rename file use rename(),for delete file use unlink() function.These file function use any project and any script.



Example :
1) Copy file :
copy("old file path","new file path") ;

2) Rename file :
rename("old file path","new file path") ;

3) Delete file :
unlink("file path") ;

Tuesday, February 19, 2013

Ajax Callback Function Using Javascript

Hey Friends,
AJAX Means Asynchronous JavaScript and XML.
AJAX is the art of exchanging data with a server, and updating parts of a web page - without reloading the whole page.
Today we Learn About Ajax call Back Function.Its very Nice and Simple script.Its call by JavaScript.Use this Function and See the magic of it.First you have download jquery library.

Jquery Library : Click Here

Example Code(Just run this code and see the magic):
1) test.php

//Add jquery library
<script language="javascript" src="jquery.min.js"></script>
//create one javascript function
<script language="javascript">
function addNumbers() {
     var number1 = $('#number1').attr('value');
     var number2 = $('#number2').attr('value');
     $.get("data.php", { number1: number1, number2: number2 },
         function(data){
             document.getElementById('data').value=data;
            //alert("Data Loaded: " + data);
     });
}
</script>


<form method="post">
<input type="text" id="number1" value="0" /> + 
<input type="text" id="number2" value="0" />
<input type="button" onclick="addNumbers();" value="=" />
<input type="text" id="data" />
</form>


2) data.php
<?php
echo $_REQUEST['number1'] + $_REQUEST['number2'];
?>

What is Joomla CMS ?

Joomla is a free and open source CMS or content management system for publishing content on the World Wide Web and intranets.
Joomla is an award-winning content management system (CMS), which enables you to build Web sites and powerful online applications.Joomla is an open source content management system that is used to create web sites with extensible and powerful function. 

What are some real world examples of what Joomla! can do?

Joomla is used all over the world to power Web sites of all shapes and sizes. For example:
  • Corporate Web sites or portals
  • Corporate intranets and extranets
  • Online magazines, newspapers, and publications
  • E-commerce and online reservations
  • Government applications
  • Small business Web sites
  • Non-profit and organizational Web sites
  • Community-based portals
  • School and church Web sites
  • Personal or family homepages

Who uses Joomla?

Here are just a few examples of Web sites that use Joomla:

Download Joomla  : Click Here
 

Update Multiple Rows With One Sql Query

If you may need to update multiple rows of data in a table. This is no problem a lot of the time, as the fields to update may all need to be changed to the same value, in which case you might run a query like the following.

UPDATE mytable SET myfield = 'value' WHERE other_field = 'other_value';

But what about if you want to update multiple rows but you need the field set to a different value for each row? For example, maybe you have a table of categories with a field to store their display order. How would you update the display order field for each category when the order changes? Most often you will see people just run multiple queries. For example, if you are using PHP you might think to do something like this:

foreach ($display_order as $id => $ordinal) {
    $sql = "UPDATE categories SET display_order = $ordinal WHERE id = $id";
    mysql_query($sql);
}
 
Of course this will work fine, but queries in loops make me start to sweat nervously. It’s all to easy to start hammering the database with a crazy number of queries. Fortunately there is a better way! The SQL is a little more complex, but it is possible to achieve the same result using only one query. The syntax is as follows.
 
UPDATE mytable
    SET myfield = CASE other_field
        WHEN 1 THEN 'value'
        WHEN 2 THEN 'value'
        WHEN 3 THEN 'value'
    END
WHERE id IN (1,2,3)
 
For multiple Fields use below sql query .
 
UPDATE categories
    SET display_order = CASE id
        WHEN 1 THEN 3
        WHEN 2 THEN 4
        WHEN 3 THEN 5
    END,
    title = CASE id
        WHEN 1 THEN 'New Title 1'
        WHEN 2 THEN 'New Title 2'
        WHEN 3 THEN 'New Title 3'
    END
WHERE id IN (1,2,3)
 

Saturday, February 16, 2013

Difference between Primary Key and Unique Key

Primary key allows each row in a table to be uniquely identified and ensures that no duplicate rows exist and no null values are entered.
Unique key constraint is used to prevent the duplication of key values within the rows of a table and allow null values. (In oracle one null is not equal to another null).
  • KEY or INDEX refers to a normal non-unique index. Non-distinct values for the index are allowed, so the index may contain rows with identical values in all columns of the index. These indexes don't enforce any structure on your data so they are used only for speeding up queries.
  • UNIQUE refers to an index where all rows of the index must be unique. That is, the same row may not have identical non-NULL values for all columns in this index as another row. As well as being used to speed up queries, UNIQUE indexes can be used to enforce structure on data, because the database system does not allow this distinct values rule to be broken when inserting or updating data. Your database system may allow a UNIQUE index on columns which allow NULL values, in which case two rows are allowed to be identical if they both contain a NULL value (NULL is considered not equal to itself), though this is probably undesirable depending on your application.
  • PRIMARY acts exactly like a UNIQUE index, except that it is always named 'PRIMARY', and there may be only one on a table (and there should always be one; though some database systems don't enforce this). A PRIMARY index is intended as a way to uniquely identify any row in the table, so it shouldn't be used on any columns which allow NULL values. Your PRIMARY index should always be on the smallest number of columns that are sufficient to uniquely identify a row. Often, this is just one column containing a unique auto-incremented number, but if there is anything else that can uniquely identify a row, such as "countrycode" in a list of countries, you can use that instead.
  • FULLTEXT indexes are different to all of the above, and their behaviour differs more between database systems. Unlike the above three, which are typically b-tree (allowing for selecting, sorting or ranges starting from left most column) or hash (allowing for selection starting from left most column), FULLTEXT indexes are only useful for full text searches done with the MATCH() / AGAINST() clause.

Search or Find Keyword Using Php Script

Search any keyword or specific string using php programming script.use php function strstr().

Means :
strstr() means Find the first occurrence of a string .
find word from particular string using php
use strstr() maeans ‘Find the first occurrence of a string’ ,



Example :

$string = ‘website php tutplus themeforest mcxstar’;
$find = ‘php’;

if(strstr($string, $find) ===false)
{
echo ‘<BR>NO – Did not find <br/><u style="color:red;">’.$find.’</u> in <b>’.$string.’</b>’;
}
else
{
echo ‘<BR>YES – Found<br/> <u style="color:green;">’.$find.’</u> in <b>’.$string.’</b>’;
}


Output :
YES-Found php 

 

Facebook Comment Box Plugin Script

Add or Apply your comment to any where using Facebook comment Plugin.Facebook Comment Box make it simple to implement anywhere in your site.Its very nice and also you can design this box very well.Just need a Facebook Javascript library for facebook comment post.

Code :

<div id="fb-root"></div>
<pre><script type="text/javascript">// <![CDATA[
(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, ‘script’, ‘facebook-jssdk’));
// ]]>

</script>
<div data-href="https://www.dropbox.com" data-num-posts="2" data-width="400"></div>

Out Put :

 

What is SQL JOIN Query ?

SQL joins are used to query data from two or more tables, based on a relationship between certain columns in these tables.A Join condition is a part of the sql query that retrieves rows from two or more tables. A SQL Join condition is used in the SQL WHERE Clause of select, update, delete statements.

Sql joins are used to fetch/retrieve data from two or more data tables, based on a join condition. A join condition is a relationship among some columns in the data tables that take part in Sql join. Basically data tables are related to each other with keys.


The JOIN keyword is used in an SQL statement to query data from two or more tables, based on a relationship between certain columns in these tables.
Tables in a database are often related to each other with keys.

Different SQL JOINs

Before we continue with examples, we will list the types of JOIN you can use, and the differences between them.
  • JOIN: Return rows when there is at least one match in both tables
  • LEFT JOIN: Return all rows from the left table, even if there are no matches in the right table
  • RIGHT JOIN: Return all rows from the right table, even if there are no matches in the left table
  • FULL JOIN: Return rows when there is a match in one of the tables

Wednesday, February 13, 2013

How to Change The Firefox Setting ?

You can easily change the Mozila firefox setting.just you have to type the “about:config” in firefox addressbar and then enter. after it will show you to all the setting related to the firefox.

Example :
Add this line to address bar : about:config

Trace User IP Address Using Php Script

We can get the IP address of any visitor by using PHP. Finding the IP address is very important requirement for many scripts where we store the members or visitors details.Just use Server function and apply remote address.
Here is the code to display your ip address.

Example :

echo $ip=$_SERVER['REMOTE_ADDR']; 

//output : 216.239.51.99

Connect Mysql Database Using Php Script

You can access data in a database, you must create a connection to the database.
In PHP, this is done with the mysql_connect() function.

Syntax :
mysql_connect(servername,username,password);  

Parameter Description
servername Optional. Specifies the server to connect to. Default value is "localhost:3306"
username Optional. Specifies the username to log in with. Default value is the name of the user that owns the server process
password Optional. Specifies the password to log in with. Default is ""



The mysql_select_db() function sets the active MySQL database.
This function returns TRUE on success, or FALSE on failure.

Syntax :
mysql_select_db(database,connection)  

Parameter Description
database Required. Specifies the database to select.
connection Optional. Specifies the MySQL connection. If not specified, the last connection opened by mysql_connect() or mysql_pconnect() is used.


Final Example :

<?php
$con = mysql_connect("localhost", "root", "1233");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

$db_selected = mysql_select_db("test", $con);

if (!$db_selected)
  {
  die ("Can\'t use test_db : " . mysql_error());
  }
?>  

Create Folder Using Php Script

You can dynamically create folder By Php Script. For create folder in php use mkdir function.The mkdir function called “Makes directory”.
This function returns TRUE on success, or FALSE on failure.

Syntax :
 mkdir(path,mode,recursive,context) 

Parameter Description
path Required. Specifies the name of the directory to create
mode Optional. Specifies permissions. By default, the mode is 0777 (widest possible access).The mode parameter consists of four numbers:
  • The first number is always zero
  • The second number specifies permissions for the owner
  • The third number specifies permissions for the owner's user group
  • The fourth number specifies permissions for everybody else
Possible values (to set multiple permissions, add up the following numbers):
  • 1 = execute permissions
  • 2 = write permissions
  • 4 = read permissions
recursive Optional. Specifies if the recursive mode is set (added in PHP 5)
context Optional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream (added in PHP 5)

 Example :
$foldername = "justdial";
mkdir($foldername);

Header function in php

The header() function sends a raw HTTP header to a client.Means Header function is used to redirect one page to another page.header() must be called before any actual output is sent,either by normal HTML tags,blank lines in a file, or from PHP.

Header function Syntax  :
header(string,replace,http_response_code) 

Parameter Description
string Required. Specifies the header string to send
replace Optional. Indicates whether the header should replace previous or add a second header. Default is TRUE (will replace). FALSE (allows multiple headers of the same type)
http_response_code Optional. Forces the HTTP response code to the specified value (available in PHP 4.3 and higher)



Example :
<?php
// This results in an error.
// The output above is before the header() call
header('Location: http://www.example.com/');
?>

Saturday, February 9, 2013

Extract Numbers from String using Php

Get the Number from string using php.Its Simple by PHP to extract numbers from a String. This could be used for several things like extracting data amounts.
 Use php function extract_number() then after use regular expression function ereg_replace() and finally get the output.

Example :

$mytext = "The screen is 900px wide.".
$mytext = extract_number($mytext);

function extract_number($string) {
return ereg_replace("[^0-9]", "", $string);

echo extract_number($mytext);

//output is : 900

Automatic Refresh the Web Page

You need your web page automatic Refresh in 5 second or any second, use this meta tag. it’s a simple code, put it between HEAD tag in your page.
This script easy but powerful. Many websites use this scripts to redirect to another page or refresh the same page, for example, my website updates in every 5 minutes and I want to show user my latest content then I put this script to my page and set it refreshs in every 5 minutes.

Example :

<HEAD>
<meta http-equiv=’refresh’ content=’2;url=’file_name or URL’>
</HEAD>
// content = time (second)
// file_name = name of file you want to refresh or redirect
 

File Download using php script

File Download code using php is very simple and effective.Using this code you can download any file,doc,pdf,rar,zip,video,image etc.just you have to add file path to this function.This is done by a some line of php code. 
Download any type of file using php script.This code is help you to download any kind of file dynamically.



Example code :
//your file name add
$f="test.php";
function force_download($file)
{
//provide your directory path
$dir="";
if ((isset($file))&&(file_exists($dir.$file))) {
header("Content-type: application/force-download");
header(‘Content-Disposition: inline; filename="’ . $dir.$file . ‘"’);
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize($dir.$file));
header(‘Content-Type: application/octet-stream’);
header(‘Content-Disposition: attachment; filename="’ . $file . ‘"’);
readfile("$dir$file");
} else {
echo "No file selected";

}//end function
echo force_download($f);

What is MVC Architecture ?

MVC stands for Model,View,Controller .MVC pattern is a collabartion of three components model,view,controller.MVC pattern is a sequence of action interactions starting with view,then controller and then to model based on the data persistence.

MVC is an approach for developing interactive application ie it results in events through user interactions.Model is responsible for holding the application state,View is for displaying the current model and controller handles the event.

The main aim of MVC architecture is to separate the business logic and application data from the presentation data to the user. 

Model View Controller or MVC as it is popularly called, is a software design pattern for developing web applications. A Model View Controller pattern is made up of the following three parts:
  1. Model - The lowest level of the pattern which is responsible for maintaining data.
  2. View - This is responsible for displaying all or a portion of the data to the user.
  3. Controller - Software Code that controls the interactions between the Model and View.



 

Display Your Google Plus Counter

Display Google Like Counter of your website without any coding .just simple script for this.Add your URl to below link and see the output.

Example :

https://plusone.google.com/u/0/_/+1/fastbutton?count=true&url=http://w3schools.com

Thursday, February 7, 2013

Get Meta Tag Description using php script

Get Meta Tag description of any website using php script.There is one function in php for get meta description.Its contain two details 1) keywords 2) description.
Use this get_meta_tags("URL",true) php function.

Example : 
$x=get_meta_tags("http://phpforms.net/",true);
print_r($x);


Output :
Array ( [keywords] => php forms,html forms,web form builder,email form. [description] => Create any kind of web form in several mouse clicks! Generate a code that can be easily copied and pasted to 
any web page )

Single Login For Multiple Wordpress Domain

WordPress is web software you can use to create a beautiful website or blog. We like to say that WordPress is both free and priceless at the same time.

One Login For Mutiple Wordpress Blog Or Site Using Single Database.In order to be able to share a session cookie between both sites just use below code for it.



1) Sub Domain
    Example : example.com , test.example.com , main.example.com
          If you use sub Domain you can follow this step:

Step 1 : Open Config File (Main Domain) and add below code.

$baseurl = 'http://example.com'; // replace with your main blog url
$cookiehash = md5($baseurl);

define('COOKIE_DOMAIN', true);
define('ADMIN_COOKIE_PATH', '/');
define('COOKIEPATH', '/');
define('SITECOOKIEPATH', false);
//define('COOKIEHASH', 'vy48u9w38868t7t99jh8g137x221r5h1h8');
define('COOKIEHASH', $cookiehash);
define('AUTH_KEY',         'qKuU:a]Zc9PfkXIN@e%[>)kl+EjNK!M; AGerZfz_LdK)LEF[v@LGx4efm-u)v`y');
define('SECURE_AUTH_KEY',  'aCDUFGo3[eKwh^h+xGZF^+J#XS|{BoW_on;}$pm*qWH4nWy`QxyaT^uirF!*`*O3');
define('LOGGED_IN_KEY', 'mywu969v3tcf2uer82vxisx8k6sq2neib5qs1qt4sx383slslb5t1xep12hbtcxs');
define('NONCE_KEY', 'bde6j26r93lvwmgwydw7x3kp74r5299q8vxe832y7r616lf215142e5t4vc55j36');
define('AUTH_SALT', '3856m559klvidrx34fi574ct32r94x77bepr7638jmuw22d29883i82k76un2tm4');
define('LOGGED_IN_SALT', 'jq4p67bv772nd73w4zm6286552x755v6293qpj5fbe34fxy894trdu77h38586n2');
define('SECURE_AUTH_SALT', 'i9hlmd67n21j2u485645in9vu6v92itgfmja6bjfbc36gqc673svlis9u789316p');
define('TEST_COOKIE', 'TEST_COOKIE'.COOKIEHASH);


Step 2 : Open Config File (Sub Domain wordpress setup) and add below code.

 $baseurl = 'http://example.com'; // replace with your main blog url
$cookiehash = md5($baseurl);

define('COOKIE_DOMAIN', '.example.com');
define('ADMIN_COOKIE_PATH', '/');
define('COOKIEPATH', '/');
define('SITECOOKIEPATH', false);
//define('COOKIEHASH', 'vy48u9w38868t7t99jh8g137x221r5h1h8');
define('COOKIEHASH', $cookiehash);
define('AUTH_KEY',         'qKuU:a]Zc9PfkXIN@e%[>)kl+EjNK!M; AGerZfz_LdK)LEF[v@LGx4efm-u)v`y');
define('SECURE_AUTH_KEY',  'aCDUFGo3[eKwh^h+xGZF^+J#XS|{BoW_on;}$pm*qWH4nWy`QxyaT^uirF!*`*O3');
define('LOGGED_IN_KEY', 'mywu969v3tcf2uer82vxisx8k6sq2neib5qs1qt4sx383slslb5t1xep12hbtcxs');
define('NONCE_KEY', 'bde6j26r93lvwmgwydw7x3kp74r5299q8vxe832y7r616lf215142e5t4vc55j36');
define('AUTH_SALT', '3856m559klvidrx34fi574ct32r94x77bepr7638jmuw22d29883i82k76un2tm4');
define('LOGGED_IN_SALT', 'jq4p67bv772nd73w4zm6286552x755v6293qpj5fbe34fxy894trdu77h38586n2');
define('SECURE_AUTH_SALT', 'i9hlmd67n21j2u485645in9vu6v92itgfmja6bjfbc36gqc673svlis9u789316p');
define('TEST_COOKIE', 'TEST_COOKIE'.COOKIEHASH);


define('CUSTOM_USER_TABLE', 'wp_users');
define('CUSTOM_USER_META_TABLE', 'wp_usermeta');


Step 2 : Open capabilities.php File (Sub Domain wordpress setup) and add below code.
(C:\xampp\htdocs\wordpress\wp-includes\capabilities.php)

Goto line no:709 and change below line

$this->cap_key = $wpdb->prefix . 'capabilities';

Change to : (main wordpress database prifix)

$this->cap_key = $wpdb-> 'wp_capabilities';  
 

One Login For Multiple Wordpress

WordPress is web software you can use to create a beautiful website or blog. We like to say that WordPress is both free and priceless at the same time.

One Login For Mutiple Wordpress Blog Or Site Using Single Database.In order to be able to share a session cookie between both sites just use below code for it.



1) Sub Directory 
    Example : example.com , example.com/stuff , example.com/tutorials
          If you use sub directory you can follow this step:

Step 1 : Open Config File (Main wordpress setup) and add below code.

$baseurl = 'http://localhost/wordpress'; // replace with your main blog url
$cookiehash = md5($baseurl);

define('COOKIE_DOMAIN', false);
define('ADMIN_COOKIE_PATH', '/');
define('COOKIEPATH', '/');
define('SITECOOKIEPATH', false);
//define('COOKIEHASH', 'vy48u9w38868t7t99jh8g137x221r5h1h8');
define('COOKIEHASH', $cookiehash);
define('AUTH_KEY',         'qKuU:a]Zc9PfkXIN@e%[>)kl+EjNK!M; AGerZfz_LdK)LEF[v@LGx4efm-u)v`y');
define('SECURE_AUTH_KEY',  'aCDUFGo3[eKwh^h+xGZF^+J#XS|{BoW_on;}$pm*qWH4nWy`QxyaT^uirF!*`*O3');
define('LOGGED_IN_KEY', 'mywu969v3tcf2uer82vxisx8k6sq2neib5qs1qt4sx383slslb5t1xep12hbtcxs');
define('NONCE_KEY', 'bde6j26r93lvwmgwydw7x3kp74r5299q8vxe832y7r616lf215142e5t4vc55j36');
define('AUTH_SALT', '3856m559klvidrx34fi574ct32r94x77bepr7638jmuw22d29883i82k76un2tm4');
define('LOGGED_IN_SALT', 'jq4p67bv772nd73w4zm6286552x755v6293qpj5fbe34fxy894trdu77h38586n2');
define('SECURE_AUTH_SALT', 'i9hlmd67n21j2u485645in9vu6v92itgfmja6bjfbc36gqc673svlis9u789316p');
define('TEST_COOKIE', 'TEST_COOKIE'.COOKIEHASH);


Step 2 : Open Config File (Sub directory wordpress setup) and add below code.

 $baseurl = 'http://localhost/wordpress'; // replace with your main blog url
$cookiehash = md5($baseurl);

define('COOKIE_DOMAIN', false);
define('ADMIN_COOKIE_PATH', '/');
define('COOKIEPATH', '/');
define('SITECOOKIEPATH', false);
//define('COOKIEHASH', 'vy48u9w38868t7t99jh8g137x221r5h1h8');
define('COOKIEHASH', $cookiehash);
define('AUTH_KEY',         'qKuU:a]Zc9PfkXIN@e%[>)kl+EjNK!M; AGerZfz_LdK)LEF[v@LGx4efm-u)v`y');
define('SECURE_AUTH_KEY',  'aCDUFGo3[eKwh^h+xGZF^+J#XS|{BoW_on;}$pm*qWH4nWy`QxyaT^uirF!*`*O3');
define('LOGGED_IN_KEY', 'mywu969v3tcf2uer82vxisx8k6sq2neib5qs1qt4sx383slslb5t1xep12hbtcxs');
define('NONCE_KEY', 'bde6j26r93lvwmgwydw7x3kp74r5299q8vxe832y7r616lf215142e5t4vc55j36');
define('AUTH_SALT', '3856m559klvidrx34fi574ct32r94x77bepr7638jmuw22d29883i82k76un2tm4');
define('LOGGED_IN_SALT', 'jq4p67bv772nd73w4zm6286552x755v6293qpj5fbe34fxy894trdu77h38586n2');
define('SECURE_AUTH_SALT', 'i9hlmd67n21j2u485645in9vu6v92itgfmja6bjfbc36gqc673svlis9u789316p');
define('TEST_COOKIE', 'TEST_COOKIE'.COOKIEHASH);


define('CUSTOM_USER_TABLE', 'wp_users');
define('CUSTOM_USER_META_TABLE', 'wp_usermeta');



Step 3 : Open capabilities.php File (Sub Directory wordpress setup) and add below code.
(C:\xampp\htdocs\wordpress\wp-includes\capabilities.php)

Goto line no:709 and change below line

$this->cap_key = $wpdb->prefix . 'capabilities';

Change to : (main wordpress database prifix)

$this->cap_key = $wpdb-> 'wp_capabilities'; 

Monday, February 4, 2013

Check if a string contains numbers by Mysql

how do I check if a string in a MySQL field contains a number then delete them?
 
tbl_tags
 -------------
| id | tag    |
 -------------
| 1  | hello  |
| 2  | hello2 |
| 3  | 2hello |
| 4  | hel3lo |
                   -------------

The only way I can think of is to do each number individually and use LIKE '%1%' OR LIKE '%2%' etc. But there must be an easier way?

Check out the MySQL Regex methods. Something like the following should work.
SELECT * FROM table WHERE tag REGEXP '[0-9]'


Replace character or word using Sql Query

Hi Friends,
Here We learn about how to replace string,character or word to given string using mysql or sql query.For doing this you can use " REPLACE() " Function.
Example :
UPDATE tablename SET fieldname = REPLACE(fieldname,'OLD TEXT','NEW TEXT')