For sending emails with attachments, we can use ZEND library, but it make no sense for me to use such a big library just for sending email. Here is simple solution for this problem with couple of simple lines.
Friday, December 14, 2012
Sending E-mails with attachments
For sending emails with attachments, we can use ZEND library, but it make no sense for me to use such a big library just for sending email. Here is simple solution for this problem with couple of simple lines.
Friday, November 2, 2012
Creating custom module in Drupal 7
Drupal is very rich in terms of modules. There are hundreds of modules available on Drupal official site.
One just need to find the appropriate module and start playing with that module after installing it in his application.
But sometimes, there comes a situation when developer has to develop his own module. Here I am writing the steps to develop a module which will create a web form. In this tutorial we will learn how to develop a web form, validating the data & submitting data into database.
But sometimes, there comes a situation when developer has to develop his own module. Here I am writing the steps to develop a module which will create a web form. In this tutorial we will learn how to develop a web form, validating the data & submitting data into database.
Friday, October 19, 2012
Thought
When things in your life seem almost too much to handle, when 24 hours in a day are not enough, remember the mayonnaise jar and the 2 Beers.
A professor stood before his philosophy class and had some items in front of him. When the class began, he wordlessly picked up a very large and empty mayonnaise jar and proceeded to fill it with golf balls. He then asked the students if the jar was full. They agreed that it was.
Tuesday, October 16, 2012
Setting Environment Variable in LINUX
Environment variables in LINUX are basically the shell variable used to set configuration options and customize the shell environment under Linux.
Display Environment variables
Here is the syntax of setting environment variables
Display Environment variables
$ env
Here is the syntax of setting environment variables
Tuesday, October 9, 2012
Managing MySQL Server Logs
MySQL Server provides several logs that help us find out what activity is taking place.
MySQL provides different types of log files.
Error Log: contains information indicating when mysqld was started and stopped and also any critical errors that occur while the server is running.
General Query Log: is a general record of what mysqld is doing. The server writes information to this log when clients connect or disconnect, and it logs each SQL statement received from clients.
Binary Log: contains “events” that describe database changes such as table creation operations or changes to table data.
Error Log: contains information indicating when mysqld was started and stopped and also any critical errors that occur while the server is running.
General Query Log: is a general record of what mysqld is doing. The server writes information to this log when clients connect or disconnect, and it logs each SQL statement received from clients.
Binary Log: contains “events” that describe database changes such as table creation operations or changes to table data.
Wednesday, September 26, 2012
HL7 (Health Level Seven)
HL7 (Health Level Seven) provide a framework (and related standards) for the exchange, integration, sharing, and retrieval of electronic health information. Most healthcare IT professionals are using HL7 format for data exchange.
While working with HL7 format, it basically encode the data, the receiving end of encoded data decode the data and perform the process that data accordingly.
While working with HL7 format, it basically encode the data, the receiving end of encoded data decode the data and perform the process that data accordingly.
Tuesday, September 25, 2012
Thursday, September 20, 2012
MySQL's REPLACE()
We are in habit of using str_replace() of PHP, but MySQL also provide replace function for same purpose.
The REPLACE() function takes three parameters:
- The string or column name to do the replacement on
- What to look for
- What to replace it with
SELECT REPLACE('My name is garav', 'garav', 'Gaurav.') as result;
result: My name is Gaurav.
Working days b/w two days & Weekends b/w two dates
MySQL is very rich with built in function as it have thousands of functions. But apart from this rich library sometimes we need to create some custom function to get the task done. Today I encountered same kind of situation. I need a function which can return no. of working days between two dates and it should also return the weekend days between two days. Here is the solution for this problem. I created a user defined function to calculate working dates between two dates.
Allow or Block IPs Address - .htaccess Security
Hypertext Access, commonly shortened to htaccess, is a configuration file which controls the directory it is placed in and all the subdirectories underneath it. It's an incredibly useful feature which allows webmasters to control how many aspects of their website works. You can 301 redirect pages, change the extensions of pages, rewrite urls for better keyword ranking presence, password protect directories, Error 404 Document redirect and much much more. .htaccess provide security to allowing and blocking access to a web server from a IP address. Reasons for doing this include:
Password Protection on Directory Using .htaccess
If your files are not protected then one must think over the protection of the file. Protection can be provided in various ways like PHP login page, but it will not protect your documents, images and other media. We can protect the files using .htaccess protection. The system requires two files -- the .htaccess file and .htpasswd file.
Wednesday, September 19, 2012
Block Unwanted Referrers - .htaccess
If we want to block some unwanted referrers then we can achieve it with small bit of .htaccess code and mod_rewrite.
RewriteEngine on
RewriteCond %{HTTP_REFERER} digg.com [NC]
RewriteRule .* - [F]
Detect Android with PHP, Javascript & .htaccess
Android is a Linux-based operating system, designed primarily for touchscreen mobile devices such as smartphones and tablet computers. Andriod is initially developed by Android, Inc.
While working in web technology environment, many times we came accross the situation where we need to detect that if it is Android is not. This detection can be done in multiple ways like:
1. Using PHP
2. Using Javascript
3. Using .htaccess
It totally depends on the interest of developer, which mechnaism he/she choose to detect android.
While working in web technology environment, many times we came accross the situation where we need to detect that if it is Android is not. This detection can be done in multiple ways like:
1. Using PHP
2. Using Javascript
3. Using .htaccess
It totally depends on the interest of developer, which mechnaism he/she choose to detect android.
Tuesday, September 11, 2012
Basic Linux Commands for Developers
a. Command Line Interface (CLI)
b. Graphical User Interface (GUI)
In Command Line Interface, we generally use commands. Here is a collection of basic linux commands.
MySQL Cursors
Cursors are basically named SQL statement which we can be defined in our procedures. We can then easily look at the contents of the cursor by fetching the records from it. It’s a way for us to get information from our tables in one big chunk and then work on it. As always there is no better way to find out about them than actually doing one but because cursors require a little more code than things we have looked at previously we will need to look at the various stages before writing a procedure which uses cursors.
MySQL Stored Procedures
MySQL 5.0 finally introduces functionality for Stored Procedures. But there is always a question in our mind that what are stored procedures and why we use them. When we can use queries then what is the advantages of stored procedures?
The answer is very simple.
A stored procedure is simply a block of code that is stored on the database server.
Advantages of stored procedures?
- When we are working with stored procedures, we kept our logic on database server in compiled form. We need not to compile our queries every time. When we user queries in our code, then every time the query get compiled and after that the query return the results to the application. but when we use stored procedure, we compile the query only once and can call our stored procedure any time.
- Stored procedures can reduce network traffic. When we have to do some complex and repetitive task on the results and again we have to again apply some other logic to get more result then it will be good to use stored procedures.
Stop caching using PHP
A cache is a temporary storage area. For example, the files you automatically request by looking at a Web page are stored on your hard disk in a cache subdirectory under the directory for your browser. When you return to a page you've recently looked at, the browser can get those files from the cache rather than the original server, saving you time and saving the network the burden of additional traffic. Sometimes we don’t need caching at any particular page. We can stop caching using PHP.
Request Detection for Mobile Application
Market for mobile application is growing with a great speed. Even there are lots of mobile application created in PHP itself. Sometimes, we have common application for web and mobile but need to detect the mobile devices before rendering the content. Here is a useful code snippet to detect the source of request for application using PHP.
If application is requested by any mobile device then the function will return true else it will return false.
Wednesday, April 11, 2012
LDAP implementation using PHP
The Lightweight Directory Access Protocol is an application protocol for accessing and maintaining distributed directory information services over an Internet Protocol (IP) network. In this post we'll see that how we can connect to LDAP using PHP. Bais knowledge of PHP is required to understand this functionality.
Subscribe to:
Posts (Atom)