Flipkart

Wednesday, December 28, 2011

You probably tried to upload too large file – phpmyadmin

Here are the solutions to solve the problem:

1. Increase the values for upload_max_filesize, memory_limit and post_max_size directories in php.ini as per requirements and restart the server

2. You can upload large sql files by changing some configuration settings in C:\xampp\phpmyadmin\config.inc.php file.

  Open the config.inc.php file and look for $cfg['UploadDir'] and update it as $cfg['UploadDir'] = "upload". If you dont find just open a config.sample.inc.php and copy that line and paste into your actuall config.inc.php file and update as i mentioned above. Finally it will be:

    $cfg['UploadDir'] = "upload"

Save the file and create upload folder under phpmyadmin folder.

   C:\xampp\apps\phpmyadmin\upload\

Then copy your all .sql files into this folder.

Now when you go to phpmyadmin import page you will see  a drop down with list of .sql files below the browse button.

You can now select this and begin the import.

If your having problem in Windows 7 and  32 bit system you need verify that your values should be under 2048M, then only it will work.

Reason:

"The largest signed integer for a 32bit operating system is -2,147,483,647 - 2,147,483,647 since 2048M = 2147483648 bytes, it was going higher than it could calculate, so it was defaulting to a negative integer. Hence the reason why the log file states -2147483648 bytes."


If you get Script timeout passed, if you want to finish import, please resubmit same file and import will resume.


add $cfg['ExecTimeLimit'] = 0; this line in config.inc.php file.
By default setting for ExecTimeLimit is 300 seconds.






Monday, October 3, 2011

Strip only given Tags PHP

/**
 *
 * @param String $str
 * @param tags which needs to be strip $tags
 * @param boolean $stripContent
 * @return string
 */
function strip_only_tags($str, $tags, $stripContent=false) {
    $content = '';
    if(!is_array($tags)) {
        $tags = (strpos($str, '>') !== false ? explode('>', str_replace('<', '', $tags)) : array($tags));
        if(end($tags) == '') array_pop($tags);
    }
    foreach($tags as $tag) {
        if ($stripContent)
             $content = '(.+</'.$tag.'(>|\s[^>]*>)|)';
         $str = preg_replace('#</?'.$tag.'(>|\s[^>]*>)'.$content.'#is', '', $str);
    }
    return $str;
}

Remove array Element based on key value PHP

/**
 * Remove array Element based on key value
 * @param $arr
 * @param $key
 * @return array
 */
function array_pop_by_key($arr, $key) {
    $array_keys = array_keys($arr);
    foreach($arr as $array_key => $value) {
        if($array_key == $key) {
            unset($arr[$key]);
        }
    }
    return $arr;

}

Tuesday, September 6, 2011

Get Drupal Logo Path

Below is the code to get the Active site logo path in Drupal:

$logo = theme_get_setting('logo');

Thursday, July 21, 2011

Add Input Format to Textarea in Custom Module

To apply input formats to any textarea in our custom module forms we can use below code:

$form['format'] = filter_form(FILTER_FORMAT_DEFAULT);

example:
$form['body'] = array(
    '#type' => 'textarea',
    '#title' => t('Body'),
    '#default_value' => 'sample',
  );
$form['format'] = filter_form(FILTER_FORMAT_DEFAULT);


If you are creating Textarea under Fieldset then we have to apply filedset name to that format element as array like:

$form['filedset']['format'] = filter_form(FILTER_FORMAT_DEFAULT);

Tuesday, July 12, 2011

Wednesday, June 22, 2011

Drupal Module List

Here is the link where you can find all the module list based on the usage per week.

http://drupal.org/project/usage


Below you can find the video which explains the usage of the each module in real time.

http://gotdrupal.com/videos/top-drupal-modules


Monday, June 20, 2011

Reset admin(uid = 1) password in drupal 7

When the password for the user to Drupal (the administrator) is lost and the e-mail notification does not work, you can set the password via an SQL query.

But you must first generate a password hash that apply to your site.

Run the following commands from the command line, in the Drupal root directory:
For Linux:
./scripts/password-hash.sh newpassword

For Windows:
php .\scripts\password-hash.sh newpassword 

Then it will generate the Hash Password which somethink like
$S$CTo9G7Lx28rzCfpn4WB2hUlknDKv6QTqHaf82WHTsTHiod

Then execute the following query on the Drupal database:
UPDATE users SET pass ='thepasswordhash' WHERE uid = 1; 

OR you can use below code to get the Password:

require_once 'includes/password.inc';
echo user_hash_password('newpassword'); 
die();

Add above lines in index.php below this
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);


And refresh it .

Friday, June 17, 2011

Downloaded modules not showing up Drupal

There are mant reasons to not displaying downloaded modules in admin->site_build->modules. I f you face similar issue then please check below methods to resolve it

Run Cron Manually
Apply Permission to 755 to modules folder
Check whether same module is existing with other name(Check file names in side the module folder)
safe_mode should be OFF(check in phpinfo())

Friday, June 10, 2011

Run Linux on Windows Using VMWare Player

Here is the Good article links which explains clearly how can we install Linux on windows like any other Program using VMWare Player


http://www.lifehack.org/articles/technology/beginners-guide-run-linux-like-any-other-program-in-windows.html


http://www.makeuseof.com/tag/3-ways-to-install-linux-on-windows-or-mac/

Get Firefox Bookmarks from Hard Drive

If you see files on your hard drive, you can get the HTML file that stores all bookmarks. It is stored in the Profiles folder created by Mozilla.

In Windows XP/2000
C:\Documents and Settings\username\Application Data\Mozilla\Firefox\Profiles\xxxxx.default

In Windows Vista
C:\Users\username\AppDataRoaming\Mozilla\Firefox\Profiles\xxxxxxxx.defaultbookmarks.html

In Windows 98 & ME
C:\WINDOWS\Application Data\Mozilla\Firefox\Profiles\xxxxxxxx.defaultbookmarks.html

You can import bookmarks and the location of files from your old hard drive in Firefox or IE on your computer.









Implement Start Number and End Number of the Search Results in Drupal

Here is the code for implement start result and end result of the search results in Drupal.
 First we need to define Global variables of the Pager.


global $pager_page_array, $pager_total, $pager_total_items;

//establish page variables
  $total_pages = $pager_total['0'];
  $total_page_count = $total_pages - 1;
  //approx number of results based on page count
  $approx_results = $total_pages * 10;
  //calculate range
  $page_number = $pager_page_array['0'];
  $start_result = $page_number * 10 + 1;
  $end_result = $page_number * 10 + 10;

Customize "Your search yielded no results" Text in Search Results Drupal

Below is the sample code for customizing the "Your search yielded no results"  message in Template.php file

function theme_name_box($title, $content, $region = 'main') {

  if ($title == 'Your search yielded no results')

  {

    $title = 'Sorry, we couldn\'t find what you were looking for';
    $content = 'Check if your spelling is correct.';
}

 $output = '<div style="margin:10px"><h3>'. $title .'</h3>'. $content .'</div>';

  return $output;

}

Wednesday, June 8, 2011

Ajax Module With Image Button Drupal

If you are using Ajax module for Drupal Forms which having image button, then you can not submit the form.
To fix that kind of issue then we have to use  '#button_type' => 'submit ajax-trigger', attribute to submit button. Below is the sample code...

$path = drupal_get_path('theme', 'tradenet').'/images/image_button.png';
      $form['#ajax'] = array(
        'enabled' => TRUE
      );
      $form['submit'] = array(
             '#type' => 'image_button',
             '#access' => 1,
             '#button_type' => 'submit ajax-trigger',
             '#src'=>$path,
             '#ajax' => array('submitter' => TRUE ),

            
          );

Remove colon from label Drupal

To remove Colon from label for form elements just add this below code in to your template.php of the active theme. And replace Theme with your theme name. You can find Original code at includes/form.inc

 
function theme_form_element($element, $value) {
  // This is also used in the installer, pre-database setup.
  $t = get_t();

  $output = '


  if (!empty($element['#id'])) {
    $output .= ' id="'. $element['#id'] .'-wrapper"';
  }
  $output .= ">\n";
  $required = !empty($element['#required']) ? '*' : '';

  if (!empty($element['#title'])) {
    $title = $element['#title'];
    if (!empty($element['#id'])) {
      $output .= ' \n";
    }
    else {
      $output .= ' \n";
    }
  }

  $output .= " $value\n";

  if (!empty($element['#description'])) {
    $output .= '
'. $element['#description'] ."
\n";
  }

  $output .= "
\n";

  return $output;
}

Friday, June 3, 2011

Drupal 7 supports RDF

RDF (Resource Description Framework), which is a standard for encoding metadata and other information on the Semantic Web. In the Semantic Web, data processing applications using the dissemination of structured information in a decentralized and distributed all over the web today. RDF is an abstract, how to break information into separate pieces, and even if it is more popularly known in / RDF XML syntax, RDF can be stored in different formats. This article discusses the abstract RDF model, two specific serialization formats such as RDF is used and how it differs from the standard XML, the higher the level of the RDF semantics, best practices, implementation and querying RDF data sources.

Here are the some good Video Tutorials about RDF:




PhpPgAdmin First time Login Problem

A problem that occurs very often the error message "Access is prohibited for safety reasons," which occurs when a user tries to access a blank password, a common (presumably well-protected) on development machines. For such access, set ['extra_login_security'] to FALSE in the conf/config.inc.php.

['extra_login_security'] = false;

Wednesday, June 1, 2011

Configure PostgreSQL in WAMP Server

Here is the good PDF file which explains how to install PostgreSQL in WAMP server.

Installing-WampServer2-0c-With-PostgreSQL

If you are using php 5.2.6, there is some problem in adapter of php5.2.6, thats it is unable connect to PostgreSQL. For making connection we are using adapter of php5.2.5. you can download dll files using below link if you dont find in online.

php5.2.4 dll files

Wednesday, May 25, 2011

Write ASCII codes in Text Editors

To write some charecters, letters or symbols which are not available in our keyboard, portable personal computers, notebooks, laptops, etc.. we can print using ASCII code.
Below is the example to print symbols.

1) Open your favourite Text Editor.

2) Press the "ALT KEY" in your keyboard and hold it, do not release the key.

3) In the numeric keypad type the numbers "131", that correspond to the ASCII code for the character, letter or symbol "â" .

4) Release "ALT KEY" to Print ASCII Code.

Here is the link for detailed information



Saturday, May 14, 2011

Google SMS Channels: Send SMS Text Messages to your Group for Free

Now we can send SMS to our mobile numbers for free. Google has introduced service called Google SMS Channels. Using this service you can subscribe to news alerts, blog updates and other kinds of information like horoscopes, jokes, stocks or even cricket scores via SMS text messages.

Here  you can Subscribe to Service.

For more information Click Here.


Thursday, May 12, 2011

Apply a patch to a drupal Module from Windows

Using Eclips we can easily apply patch to drupal module.Below are the steps..


Eclipse
To apply patches to code using Eclipse:

1. Menu > windows > open perspective > others > team synchronizing
2. Open the patch file, select all text and copy it to clipboard (Ctrl+ C)
3. Menu > project > apply patch
4. Select clipboard, click next, select the file you want to patch, click finish or next to setup patching options.

Thursday, May 5, 2011

28 HTML5 Features, Tips, and Techniques

Here are the 28 new features coming with HTML5.Presently Chrome, IE9 and Firefox4 supporting HTML5.

  • New Doctype
  • The Figure Element
  • Redefined
  • No More Types for Scripts and Links
  • To Quote or Not to Quote.
  • Make your Content Editable
  • Email Inputs
  • Placeholders
  • Local Storage
  • The Semantic Header and Footer
  • More HTML5 Form Features
  • Internet Explorer and HTML5
  • hgroup
  • Required Attribute
  • Autofocus Attribute
  • Audio Support
  • Video Support
  • Preload Videos
  • Display Controls
  • Regular Expressions
  • Detect Support for Attributes
  • Mark Element
  • When to Use a
  • What to Immediately Begin Using
  • What is Not HTML5
  • The Data Attribute
  • The Output Element
  • Create Sliders with the Range Input


Please  click here to know detail information.

Good Video for HTML5 beginners

Wednesday, April 27, 2011

Thursday, April 7, 2011

Eliminate Viruses from Your Pen Drive

Published on February 5, 2009
An easy way for computers get a virus is from the use of pen drives (also known as USB devices or flash drives). Many viruses like the Ravmon virus and Heap41, which is a worm, are not detected by the usual anti-virus software. These viruses spread rapidly through USB devices. Suma Munireddy—our Employee Journalist from Bangalore—sent us a useful tip on how to protect your computer from viruses spread through USB devices.
1. Plug your pen drive or USB device to the computer.
2. After a few moments, a dialog box will pop up. Ignore this dialog box by clicking Cancel.
3. Now go to Start --> Run and type cmd to open the Command Prompt window.
4. In the Command window, type the USB drive letter and then press Enter. For instance, the drive letter for your USB device may be “E:” In this case, type “E:” in the Command window and press Enter.
5. Then, type dir/w/o/a/p and press Enter.
You will now get a list of files. In the list, see if you have any of the following:

 *   Autorun.inf
 *   New Folder.exe
 *   Bha.vbs
 *   Iexplore.vbs
 *   Info.exe
 *   New_Folder.exe
 *   Ravmon.exe
 *   RVHost.exe
 *   Any other files with .exe extension
If you notice any of the files above, type attrib -h -r -s -a *.* and press Enter.
Now delete each of the above files by typing the following command: del "filename" (for instance, del autorun.inf).
That’s all there is to it! Now just scan your USB drive with the anti-virus software you have to ensure that your pen drive is really free of all viruses.

Friday, March 18, 2011

extend CCK-fields with custom formatters

We can create new custom formatter for CCK fields using hook_field_formatter_info(), below is the example


/**
* Implementation of hook_field_formatter_info().
*/
function myModule_field_formatter_info() {
 
$formatters = array();
  if (
module_exists('filefield')) {
     
$formatters['myFormatter'] = array(
       
'label' => t('My Formatter'),
       
'field types' => array('filefield'),
       
'multiple values' => CONTENT_HANDLE_CORE,
      );
  }
  return
$formatters;
}
/**
* Theme function for myFormatter from hook_field_formatter_info.
* @param $element
*   an array of formatter info and the item to theme. look in $element['#item'] for the field item to theme.
*/
function theme_myModule_formatter_myFormatter($element) {
  return
"themed element"
}
/**
* Implementation of hook_theme().
*/
function myModule_theme($existing, $type, $theme, $path) {
  return array(
   
'myModule_formatter_myFormatter' => array(
     
'arguments' => array('element' => NULL),
    ),
  );
}
?>

Wednesday, March 16, 2011

Friday, February 18, 2011

Get number of weeks between 2 dates

function weeks_between($datefrom, $dateto)
{
    $datefrom_arr = explode("-", $datefrom);
    $datefrom = mktime(0,0,0,$datefrom_arr[1], $datefrom_arr[2], $datefrom_arr[0]);
                //echo date('Y-m-d',mktime(0,0,0,$datefrom_arr[1], $datefrom_arr[2]+7, $datefrom_arr[0]));
               
                $dateto_arr = explode("-",$dateto);
                $dateto = mktime(0,0,0,$dateto_arr[1], $dateto_arr[2], $dateto_arr[0]);
               
    $day_of_week = date("w", $datefrom);
    $fromweek_start = $datefrom - ($day_of_week * 86400) - ($datefrom % 86400);
    $diff_days = days_between($datefrom, $dateto);
    $diff_weeks = intval($diff_days / 7);
    $seconds_left = ($diff_days % 7) * 86400;

    if( ($datefrom - $fromweek_start) + $seconds_left > 604800 )
        $diff_weeks ++;

    return $diff_weeks;
}

function days_between($datefrom,$dateto){
    $fromday_start = mktime(0,0,0,date("m",$datefrom),date("d",$datefrom),date("Y",$datefrom));
    $diff = $dateto - $datefrom;
    $days = intval( $diff / 86400 ); // 86400  / day

    if( ($datefrom - $fromday_start) + ($diff % 86400) > 86400 )
        $days++;

    return  $days;
}

Friday, January 28, 2011

Send Text Messages with PHP

PText messaging has become extremely widespread throughout the world — to the point where an increasing number of web applications have integrated SMS to notify users of events, sales or coupons directly through their mobile devices.

For more Information:

http://net.tutsplus.com/tutorials/php/how-to-send-text-messages-with-php/

Introduction to creating desktop applications with PHP and Titanium

We can now create desktop applications without learning a completely new programming language! That is with the help of a free and open source tool called "Titanium". Whats more you will use your existing CSS and Javascript and PHP knowledge.

For more Information Visit:

http://www.sanisoft.com/blog/2011/01/03/introduction-to-creating-desktop-applications-with-php-and-titanium/