phprockers-logo

Simple way to create a widget in wordpress

1 comments
First Step: Goto this directory-localhost/yourwordpressname/wp-content/plugins.
Second Step: Create a folder for creating a widget in above directory.

Third Step: Inside the folder, Create a .php file and copy below codes.
Fourth Step: Goto wordpress administrator, see left sidebar, click plugins and activate your plugin.
Fifth Step: Finally Goto wordpress widget  and find the your widget name here. Then you have to use, where you want in widgetized area in wordpress.

Guides for creating a complete widgets in WordPress 3.3

0 comments
The first thing we have to do is load our widget when necessary. WordPress provides the widgets_init action hook that will allow us to do this. In WordPress 3.1, this action hook is fired right after the default WordPress widgets have been registered.

Note: This can be used to all wordpress versions


<?php

/**
* Plugin Name: Example Widget
* Plugin URI: http://phprockers.blogspot.com/p/wordpress.html
* Description: A widget that serves as an example for developing more advanced widgets.
* Version: 1.0
* Author: Ramakrishnan V.
* Author URI: http://phprockers.blogspot.com

*
*/

Uploading Files with PHP

1 comments
This script will allow you to upload files from your browser to your hosting, using PHP. The first thing we need to do is create an HTML form that allows people to choose the file they want to upload. 

<form enctype="multipart/form-data" action="upload.php" method="POST"> 
<lable> Please choose a file: </lable>
<input name="uploaded" type="file" /><br /> 
<input type="submit" value="Upload" /> 
</form> 
 
This form sends data to the file "upload.php". Then we can easily get the uploaded information using file function in upload.php.

How To Optimize Your Site With GZIP Compression

0 comments
Compression is a simple, the effective way to save bandwidth and speed up your sites. I hesitated when recommending gzip compression when speeding up your javascript because of problems in older browsers.

Most of my traffic comes from the modern browsers, and quite frankly, most of my users are fairly technology-savvy. I don't want to slow everyone else down because somebody is the chugging along on IE on Windows Operating Systems. Google and Yahoo browsers are using gzip compression.

Before we start, I should explain what content encoding is. When you request a file like http://www.gmail.com/index.html, your browser talks to a web server. 


How to get URL of first image in a post

1 comments

We can easily grab the first image from the post, and display it. 


// Get URL of first image in a post
function get_first_image() {
         global $post;
         $first_img = ''; 
         ob_start();
         ob_end_clean();
         $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
         $first_img = $matches [1] [0];
         if(empty($first_img)){
                  $first_image = "/images/default.jpg";
        }
        return $first_image;
}


<?php echo catch_that_image() ?>

How to write a WordPress Plugin?

0 comments
Before we move on coding a plugin, please make sure you remember the following coding practices.

1. Always you chose a unique name to your plugin so that it doesnt collide with names used in other plugins.

2. Make sure you comment wherever and whenever necessary in the code.

3. You will to test the plugin in your localhost (using xampp) along with latest version of wordpress.
Plugin Files & Names

What is mean by Wordpress?

0 comments
WordPress is not just a blogging platform and it is such a powerful CMS with unlimited capabilities, besides having a huge user base. Almost anything can be scripted with wordpress.

Customize your permalinks in wordpress

0 comments
%hour% – The hour of the time stamp of your post (1-24)
%minute% – The minute of the time stamp of your post (1-60)
%second% – The second of the time stamp of your post (1-60)
%category% – The category slug (wordpress-tutorials)
%author% – The author’s name (Leland)

Beauityful Short Story

0 comments
Little girl and her father were crossing a bridge.The father was kind of scared so he asked his little daughter,"Sweetheart, please hold my hand so that you don't fall into the river."The little girl said, "No, Dad. You hold my hand.""What's the difference?" Asked the puzzled father."There's a big difference," replied the little girl.
"If I hold your hand and something happens to me,chances are that I may let your hand go.But if you hold my hand, I know for sure that no matter what happens,you will never let my hand go." In any relationship, the essence of trust is not in its bind, but in its bond. So hold the hand of the person who loves you rather than expecting them to hold yours.....

what is CMS in php

0 comments
Content Management System (CMS) that provides you with the tools you need to easily create and manage your website. With tons of features and incredibly flexible. A Content Management System ( CMS ) is used to add, edit, and delete content on a website.

How to delete the Queue in Amazan?

1 comments
// Delete a queue

$sqs = new AmazonSQS();
$response = $sqs->delete_queue('https://sqs.us-east-1.amazonaws.com/0123456789/example-queue');

// Success?
var_dump($response->isOK());

How to list the Queues in Amazan?

0 comments
1. Method:

// List queues
$sqs = new AmazonSQS();
$response = $sqs->list_queues();

// Success?
var_dump($response->isOK());

2.Method
// List queues with prefix 'a'
$sqs = new AmazonSQS();
$response = $sqs->list_queues(array(
'QueueNamePrefix' => 'a'));

// Success?
var_dump($response->isOK());

How to send message via Queue in Amazon?

0 comments
The SendMessage action delivers a message to the specified queue.

// Send a message to the queue
$sqs = new AmazonSQS();
$response = $sqs->send_message('example-queue', 'This is my message.');

// Success?
var_dump($response->isOK());

Explain about the $_GET variable of PHP?

0 comments
This GET variable is executed when a request is sent from the user for information. This GET gets executed on the server and then information is sent back to the user. The information transmitted through this GET variable is viewable by everyone and is displayed in the address bar of the browser. A maximum of 100 characters is sent by the GET variable.

Difference between mysql_connect and mysql_pconnect?

0 comments
1. mysql_connection must be closed, we can't use this to connect another database means it is suitable for only one database accessing......

2.mysql_pconnect means opens a persistent connection, with this we use same host name, username, and password. we can access different databases at a time in the same program. we can't close the connection.

PHP interview Questions and Answers

0 comments
1. What is CAPTCHA?

CAPTCHA stands for Completely Automated Public Turing Test to tell Computers and Humans Apart. To prevent the users from using bots to automatically fill out forms. CAPTCHA programmers will generate an image containing distorted images of a string of numbers and letters. Computers cannot determine what the numbers and letters are from the image but humans have great pattern recognition abilities and will be able to fairly accurately determine the string of numbers and letters. By entering the numbers and letters from the image in the validation field, the application can be fairly assured that there is a human client using it. To read more look here:
http://en.wikipedia.org/wiki/Captcha

what is the difference between print and echo in php

0 comments
1. echo is faster than print.
2. print returns a int value and echo returns no value / a void value. 
3. print cannot take multiple expressions

Whats are the differences between Get and post methods in php?

0 comments
GET method have not security because of data view in addressbar.
POST method have security of data.

With GET we can send only 4 kb data but with POST there is no limit and also it is secure than GET.

What is the difference between mysql_fetch_object and mysql_fetch_array?

0 comments
Mysql_fetch_object returns the result from the database as objects while mysql_fetch_array returns result as an array. This will allow access to the data by the field names.

E.g. 
using mysql_fetch_object field can be accessed as $result->name &
using mysql_fetch_array field can be accessed as $result[name]

Explain the ternary conditional operator in PHP?

0 comments
Expression preceding the ? is evaluated, if it’s true, then the expression preceding the : is executed, otherwise, the expression following : is executed. 

if(exp1?exp2:exp3 )

If exp1 condition is true, exp2 will be print. If exp1 is false, exp3 will be print.

What is meant by urlencode and urldecode?

0 comments
string urlencode(str)

Where str contains a string like this “hello world” and the return value will be URL encoded and can be use to append with URLs, normaly used to appned data for GET like someurl.com?var=hello%world


string urldocode(str)


This will simple decode the GET variable’s value

Like it echo (urldecode($_GET_VARS[var])) will output “Hello world”

How To Get the Uploaded File Information in the Receiving Script?

0 comments
$_FILES[$fieldName]['name'] - The Original file name on the browser system.

$_FILES[$fieldName]['type'] - The file type determined by the browser.

$_FILES[$fieldName]['size'] - The Number of bytes of the file content.

$_FILES[$fieldName]['tmp_name'] - The temporary filename of the file in which the uploaded file was stored on the server.

$_FILES[$fieldName]['error'] - The error code associated with this file upload.

How can we retrive value from one database server and store them another database server using php?

0 comments
$db=mysql_pconnect("host","username","pssword"); 
mysql_select_db("dtabase name",$db); 
$query="select * from the table"; 
$res=mysql_fetch_object(mysql_query($query)); 
mysql_close($db);

//second Database
$db=mysql_pconnect("secondhost","username","pssword"); mysql_select_db("dtabase name",$db); 
$query="insert into tablename values($res)";
mysql_query($query); 
mysql_close($db);

What is the difference between ereg_replace() and eregi_replace()?

0 comments
ereg_replace() is case sensitive like “phprockers” cannot be treated as “PhpRockers” and eregi_replace() is not case sensitive where “test” could be treated as “PhpRockers”.

eregi_replace() function is same as ereg_replace() except that it ignores case distinction when matching alphabetic characters.

Notice: Undefined index: view in C:\xampp\htdocs\vsl\components\com_content\views\article\view.html.php on line 156Notice: Undefined index: view in C:\xampp\htdocs\vsl\components\com_content\views\article\view.html.php on line 158

0 comments
Notice: Undefined index: view in C:\xampp\htdocs\vsl\components\com_content\views\article\view.html.php on line 156Notice: Undefined index: view in C:\xampp\htdocs\vsl\components\com_content\views\article\view.html.php on line 158

I get this error when i click on a listing, but it still shows the listing. Any ideas?

from this code .... change to

if($menu && $menu->query['view'] != 'article')
{
switch ($menu->query['view'])

this...

if($menu && isset($menu->query['view']) && $menu->query['view'] != 'article')
after you replace this code ... then you get good answer.
 


 


 

What is the difference between require() and include() in PHP?

0 comments
if you require() a file that can't be loaded,if it isn't there, then it generates a fatal error which will halt the execution of the page completely.Then no more output will be generated. 
if you include() a file that can't be loaded, if it isn't there, then it generates a warning error and continue building the page.

How to create a forum and give the permission for that forum in phpBB3?

0 comments
1) Login to Admin

2) In bottom of the page click "Administrator Control Panel".

3) In top of the page, Go to Forums tap.

4) Click Manage forums -> create new category for create a new forum.

5) Then create new forum under the category.

Modules vs Components

0 comments


 Modules   Components 
Complexity  Low  Usually medium to high
Visibility  Various   Single Page
Position   Various   Main Body only
Configuration   Low  Extensive

Difference between component, module & plugin in joomla

0 comments
A Plugin will manipulate output already generated by the system. It typically does not run as a stand-alone piece but takes data from other sources (i.e. the content) and manipulates it before outputting to the user window. A plugin typically does not display directly to a user but does it's work behind the scenes.

A module is typically considered to be an add-on to the site that extends the functionality of another part of the system. It usually has fewer options that are configurable by the end user and most of the time does not handle any storing of information into the database. A module usually occupies a secondary portion of the web page and is not considered the primary focus of a page.

Why you should use Drupal?

0 comments
  1. Easy to use (even if you don't know html, php)
  2. Lots of modules
  3. Lots of themes
  4. You can make a website in terms of hours, even minutes 

What can you create with Drupal?

0 comments
  1. Simple n-number-of-pages static website
  2. Simple personal homepage
  3. Company website
  4. Weblog
  5. Dating website
  6. Myspace-like website
  7. (insert your favorite type of website here) 

Drupal Means:

0 comments
Drupal is CMS - Content Management System. It means you somehow "manage content" with it.The important thing to understand is that most of the content in Drupal is made up of nodes. Nodes can have comments, and comments can be submitted by users. 

Define PHP

1 comments
The PHP Hypertext Preprocessor is a programming language that allows web developers to create dynamic content that interacts with databases. PHP is basically used for developing web based software applications.Rasmus Ledorf is the father of PHP

Best Seller Module Uses in Magento

1 comments
In Magento Admin,

CMS->Manage Pages -> create home page and add a below code in this page.

{{block type="bestsellers/list" name="home.bestsellers.list" alias="product_homepage" template="catalog/product/list.phtml"}}

Then you put the link and execute "http://localhost(your domain name) /magentosample (your magento folder name) /index.php/bestsellers-list"...... it will show which one sold more in products. It will appear in your magento home page.

How to solve "click to this page and activate this control" for flash files integrated to joomla in IE7?

0 comments
1) create sample.js file in root path.
2) Then you put following code in this page.
fls = document.getElementsByTagName("object"); for (var a = 0; a < fls.length; a++){fls[a].outerHTML = fls[a].outerHTML;}
3) Then write a script in footer file or <div class="footer">,
<script type="text/javascript" src="http://www.yourwebsite (or) your domain.com/iefix.js"></script>
then you get good result....