Posts

search key word in whole Database in mysql and php

Below is the code for key word analysis, $database = 'databasename';$criteria = '*keyword*'; // you can use * and ? as jokers $dbh = new PDO("mysql:host=127.0.0.1;dbname={$database};charset=utf8", 'root', ''); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $tables = $dbh->query("SHOW TABLES"); while (($table = $tables->fetch(PDO::FETCH_NUM)) !== false){ if(strpos($table[0], "cache") === false && strpos($table[0], "sessions") === false && strpos($table[0], "watchdog") === false){ $fields = $dbh->prepare("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = ? AND TABLE_NAME = ?"); $fields->execute(array ($database, $table[0])); $ors = array (); while (($field = $fields->fetch(PDO::FETCH_NUM)) !== false) { $ors[] = str_replace("`", "``", $field[0]) . ...

Drupal Memcache setup

Image
Memcached Figure 1. The Memcached client library is responsible for sending requests to the correct servers. Step 1: Application requests keys foo, bar and baz using the client library, which calculates key hash values, determining which Memcached server should receive requests. Step 2: Memcached client sends parallel requests to all relevant Memcached servers. Step 3: Memcached servers send responses to the client library. Step 4: Memcached client library aggregates responses for the application. Install Memcache with Drupal: Windows XP: a. Install the Memcached Service Download memcached binaries for Win32 from http://jehiah.cz/projects/memcached-win32/ Unzip the binaries in a directory (eg. c:\memcached) Run the command “c:\memcached\memcached.exe -d install” for installing the service. Start the server using “c:\memcached\memcached.exe -d start” Server will be listening to port ...

Simple excel export using PHP

Step 1. Add the below header(code) in excel.php file.  header("Content-type: application/xls");  header("Content-Disposition: attachment; filename=user.xls");  header("Pragma: no-cache");  header("Expires: 0"); Step2 : Construct a HTML table and assign to a php variable. $test="<table  cellspacing='0' cellpadding='0' border='1'> <tr> <td><b>Email</b></td> <td><b>Created</b></td> <td><b>First name</b></td> <td><b>last name</b></td> <td><b>Sign up</b></td> </tr>"; $test .="<tr> <td><b>abc@gmail.com </b></td> <td><b>17th Jan 2013</b></td> <td><b>Romel</b></td> <td><b>Christopher</b></td> <td><b>1</b></td> </tr></table>"; Step...

How to force PDF/Image to download in PHP website?

I have used the below code in reference to php.net, Please try the below code it works. function downloadFile ( $fullPath ){   // Must be fresh start   if( headers_sent () )     die( 'Headers Sent' );   // Required for some browsers   if( ini_get ( 'zlib.output_compression' ))     ini_set ( 'zlib.output_compression' , 'Off' );   // File Exists?   if( file_exists ( $fullPath ) ){         // Parse Info / Get Extension     $fsize = filesize ( $fullPath );     $path_parts = pathinfo ( $fullPath );     $ext = strtolower ( $path_parts [ "extension" ]);         // Determine Content Type     switch ( $ext ) {       case "pdf" : $ctype = "application/pdf" ; break;       case "exe" : $ctype = "application/octet-stream" ; break;     ...

How to import device width based CSS file?

To specifically call a stylesheet you need to use the link tag in your HTML, see the below  Try the below  <link rel = "stylesheet" type = "text/css" media = "screen and (min-width: 701px) and (max-width: 900px)" href = " css/medium.css" / >                                                           (OR) <link rel = "stylesheet" type = "text/css" media = "only screen and (max-device-width: 780px)" href = "max-device-width-780px.css" / >

Floating block using JQuery

$(function() { var fixedelement = $("#left_fixed_div"); var offset = fixedelement.offset(); var topPadding = 15; $(window).scroll(function() { if ($(window).scrollTop() > offset.top) { fixedelement.stop().animate({marginTop: $(window).scrollTop() - offset.top + topPadding}); } else { fixedelement.stop().animate({marginTop: 0}); };}); });

create "stay on top menu" using jquery(floating menu).

1)    Add the below Jquery in JS file, $(function(){         var menu = $('#menu'),         pos = menu.offset();                 $(window).scroll(function(){             if($(this).scrollTop() > pos.top+menu.height() && menu.hasClass('default')){                 menu.fadeOut('fast', function(){                     $(this).removeClass('default').addClass('fixed').fadeIn('fast');                 });             } else if($(this).scrollTop() <= pos.top && menu.hasClass('fixed')){              ...

How to secure drupal site

http://drupal.org/writing-secure-cod

Javascript debugger

http://www.purpleoar.co.nz/scryptik/download-shareware

How to import big .sql file in Mysql ?

Hello All, You cannot import using phpMyAdmin , if the backup file size is big. How to import big .sql  file in Mysql ? Solution: E:\xampp\mysql\bin>  mysql -u <username> -p          /* you have to change this path E:\xampp\mysql\bin , if you have installed XAMPP in different path */ mysql>password : <enter your password here> mysql> create database <databsename>                    /* if  needed */ mysql> use <databasename> mysql> source <sql file full path name eg, c:\temp\backup.sql>     /* only .sql file , not zip or gzipped files */ We can use this for local server  / shell access server only  not shared hosting server.

MySQL server gone away

Hello ,  If your project is using many modules especially big modules, may be you will also come across this problem. The problem was-                           I was uploading my database in abc.com, then it was giving following error.                            Error:  got a data bigger than max_allowed_packet                                                     While uploading database from abc.com to localhost the error was:                                                      Error:  MySQL  server gone away    ...

Video Tutorial For File Download After making payment

http://www. torontowebsitedeveloper.com/ category/video/ubercart

how to give "no link" or separator to menu in drupal

Special menu items is a Drupal module that provides placeholder and separator menu items. A placeholder is a menu item which is not a link. It is useful with dynamic drop down menus where we want to have a parent menu item which is not linking to a page but just acting as a parent grouping some menu items below it. A separator menu item is something like "-------" which is not linking anywhere but merely a mean to structure menus and "separate" menu items visually.

how to retrieve data stored in the database in different language and print in php, mysql or drupal

While retrieving the data stored in the  database in different languages, it will be retrieved as unknown format(???).   To avoid this problem and to retrieving the original values please use the below given code before your select query  mysql_query("SET NAMES utf8"); mysql_query("SET CHARACTER SET utf8");

To Hide "Log Message" or "Revision information" from node form in drupal

To Hide "Log Message" manually , use the below code in template.php function phptemplate_node_form ( $form ) {   // Remove 'Log message' text area    $form [ 'log' ][ '#access' ] = FALSE ;   return drupal_render ( $form ); } OR  use the below module http://drupal.org/project/removelogmessage

How to get the views datas inside coding in drupal

To get the view datas inside coding , Use the below coding    $display = 'page_1'; // 'page_2' or 'block_1' etc $view = views_get_view('view_name'); $vars['photos'] = $view->preview($display, arg ); $vars['photo_count'] = $view->total_rows; Note: arg should be array arg should he replaced by array($vars['row']->nid) if used template.php file templatename_preprocess_views_view_fields(&$vars) { }

How to retrieve drupal views content using PHP Code

use the following php code for retrieve drupal 6 views content: $display = 'page_1'; // 'page_2' or 'block_1' etc $view = views_get_view('view_name'); $display = $view->execute_display('block_1', $myArg); print $display['content']; ?>

How to Fetch Profile field Values in drupal

We can add additional fields in the user registration form using profile module. The following code is used to fetch these profile field values anywhere in drupal. <?php global $user; profile_load_profile ( $user ); print( $user -> profile_ [ fieldnam e ]); ?>

how to get drupal block contents(using coding)

We can display any Drupal block anywhere in the website using the code given below. <?php $block = module_invoke( [module name], 'block', 'view', [block id] ); print $block['content']; ?>  

CSS for mac

To write separate CSS for mac os ,Copy the below script into the head tag of your page <script type="text/javascript"> var csstype="inline" //Specify type of CSS to use. "Inline" or "external" var mac_css='body{font-size: 14pt; }' //if "inline", specify mac css here var pc_css='body{font-size: 12pt; }' //if "inline", specify PC/default css here var mac_externalcss='/style/macstyle.css' //if "external", specify Mac css file here var pc_externalcss='/style/pcstyle.css'   //if "external", specify PC/default css file here ///////No need to edit beyond here//////////// var mactest=navigator.userAgent.indexOf("Mac")!=-1 if (csstype=="inline"){ document.write('<style type="text/css">') if (mactest) document.write(mac_css) else document.write(pc_css) document.write('</style>') } else if (csstype==...