Thursday, 26 May 2016

What is XML ?

XML: XML stands for extensible markup language.  This is designed to store the data and describing the data.

XML provides an environment where we can create cross platform compactable files.  Cross platform compatibility means, it is not specify to any operating system, software or hardware.

XML is standard set of rules, which is given by W3C. Which is used to create tag based data. XML is called mother language because using XML we can create our own markup languages. EX: MML, VML, WML, XHTML

Differences between XML and HTML

HTML

1.     HTML is used to create the web pages
2.       HTML contains predefined tags
3.       HTML tags not case sensitive
4.       HTML is an error free language  that means it will display the data or will not display the data on   browser
5.       HTML supports both proper nesting and in proper nesting
6.       HTML providing styles for the data

XML

1.       XML used to store and describe the data. 
2.       XML contains only user defined tags 
3.       XML tags are case sensitive 
4.       XML is not an error free language that means it will display the error information on the browser
5.       XML supports only proper nesting. 
6.       XML providing the structure for the data. 

Advantages
 
  1. XML can also be used to  store the  data permanently like database
  2. XML can be used configure web resources of any web based applications
  3. XML files can also be used to given instruction to an electronic devices
  4. Using XML we can also create our own markup language
  5. XML can be used to transfer the data between un compactable languages

  
XML  Standard rules

  1. Every XML document must contain exactly one root tag
  2. Every XML tag must contain its starting tag and followed by its ending tag
  3. XML tags must  follow the case sensitive
  4. XML tags may contain child elements or attributes.
  5. Attribute must be specified using “ “ (or)  ‘ ‘.
  6. XML document must be nested
  7. Element name can contain combination of alphabets and digits.
  8. It must not begin with any digit.
  9. It must not contain any spaces
  10. It must not contain any special characters.

Wednesday, 11 May 2016

Most Common Useful MySql Queries.

At the time of MySql Query implementation, most of the time we are confusing rarely used queries. Below are the solutions for in real time scenario  MySql queries.

Get the parent Title:

SELECT *,(select vTitle from classifieds_categories c2 where c1.iParentId = c2.iId) as title FROM `classifieds_categories` c1

Get 2nd Height price:

SELECT max(vPrice) FROM `classifieds_list` where vPrice!= (SELECT max(vPrice) FROM `classifieds_list`);

Group wise latest records:


SELECT r1.* FROM `records` r1 Left join `records` r2 ON (r1.vGroup = r2.vGroup AND r2.iId > r1.iId) WHERE r2.iId IS NULL

Group wise first records:

SELECT r1.* FROM `records` r1 Left join `records` r2 ON (r1.vGroup = r2.vGroup AND r2.iId > r1.iId) WHERE r2.iId IS NULL

PHP Interview Questions Experienced


Regular PHP


1) Difference between PHP 4 & 5

2) Sessions & cookies

3) Diff Between MyIsam & INNODB Storage Engines

4) Left Join and Right Joins

5) Can you suggest any Query optimization techniques ?

6) Diff b/w Char & Varchar

7) Why use Enumeration Data type ?

8) How to use Fulltext ?

9) Connect & pConnect difference

10) Magic mathods __call, __set, __get, __constructss

11) Define vs Const vs Final

12) What are the error types in php

13) Why use ob_start()

14) What use Final Keyword ?

12) Why use and how to use Static methods ?

13) Abstract vs Interface

14) How to Call the parent constructor in side the constructor

15) What is the importance of __autoload ?

Codeigniter Framework


1) What is the different between Codeigniter 2 & Codeigniter 3

2) Explain Codeigniter Application Architecture ?

3) Can you explain Active Records ?

4) How to call the sessions ?

5) Diff B/W helpers and Libraries

6) How to call Multiple Database in Codeigniter ?

7) How to load the Languages ,libraries and helpers

8) What is the importance of Hooks ?

9) How to use joins in Codeigniter

10) How to implement the URL routing in codeigniter ?

11) How many ways to store the sessions in Codeigniter Application ?

Wednesday, 20 April 2016

Virtual host configuration for apache PHP

Below are the simple steps for Virtual host configuration process in windows. For this approach you need to change the files at 3 areas.

Change the Apache Httpd

In WAMP server open the apache path at  C:/wamp/bin/apache/Apache2.2.11/conf/httpd.conf
Here we can check the below configuration.

<Directory "c:/wamp/www/">
Order Deny,Allow
    Deny from all
    Allow from all
</Directory>


And also remove the # at httpd virtual hosts configuration file path & rewrite module path. As like below

Include conf/extra/httpd-vhosts.conf
LoadModule rewrite_module modules/mod_rewrite.so

Change the Apache Httpd Virtual Host

In this file check the virtual host port number, located at C:/wamp/bin/apache/Apache2.2.11/conf/extra/httpd-vhosts.conf

NameVirtualHost *:80

And also add the below code. This is related to  php application path.

<VirtualHost  *:80>
    DocumentRoot "C:/wamp/www/yahoo.com"
    ServerName yahoo.com
</VirtualHost>

<VirtualHost  *:80>
    DocumentRoot "C:/wamp/www/rediff.com"
    ServerName rediff.com
</VirtualHost>

<VirtualHost  *:80>
    DocumentRoot "C:/wamp/www/gmail.com"
    ServerName gmail.com
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "C:/wamp/www"
    ServerName localhost
</VirtualHost>

Add the virtual host Url's

The above all virtual Url's are  added at windows drivers path.  Below is the path of the hosts provided location. Most properly this location is under  C drive.

Windows/system32/drivers/etc/hosts



In this file add the below locations list.

127.0.0.1    localhost
127.0.0.1    yahoo.com
127.0.0.1    rediff.com
127.0.0.1    gmail.com



After adding the hosts restart the system. Now you can access the virtual hosts paths. like http://yahoo.com


that's enough....

Tuesday, 19 April 2016

PHP Javabridge Configuration

Javabridge is the bridge between the PHP and Java. If we need Java libraries in PHP, then we implement the Javabridge concept.

Requirements :

1) JDK
2) PHP
3) Apache
4) Tomcat
5) Javabridge war folder

STEP 1 : Download and install the JDK latest version.

STEP 2 :  Once installation completed, set the Environment variables.

Right click on MyComputer -> Properties -> Advanced -> Environment variables -> Double click on path, then add the bin path, like below

C:\Java\jdk1.7.0\bin;


STEP 3 :  Then check java is running or not in our system. For checking we can use command prompt.  Like C:\> javac.

Once we get the below screen, then we successfully compile the java.             
             

STEP 4 : Now you can install  the PHP, Apache and tomcat servers. Other wise you can use XAMPP or WAMP Servers. Once install the Xampp server you can run the Apache, MySql and Tomcat services.

In this example we deal with   XAMPP server.


STEP 5 :  Now we set 2 environments. One is PHP & another one is Java.

In PHP environment, you can create one project (JavaBridge) in xampp/htdocs folder. And also create index.php with below code.

 <?php

//init php java bridge

require_once "E://Testing/xampp/tomcat/webapps/JavaBridge/java/Java.inc";
$class = new JavaClass("java.lang.Class");
$class->forName("com.mysql.jdbc.Driver");

$driverManager = new JavaClass("java.sql.DriverManager");

if($driverManager)
echo "Success";
else
echo "Failure";

?>

STEP 6 :  Download the JavaBridge.war at  http://php-java-bridge.sourceforge.net/doc/download.php

STEP 7 :  Create JavaBridge folder at xampp/tomcat/webapps location, Then move the downloaded war file(JavaBridge.war) to xampp/tomcat/webapps/JavaBridge folder.

STEP 8 : Now you can go to command prompt webapps location (xampp\tomcat\webapps\)
 And run the war file. Like below

jar -xvf \JavaBridge.war

 Here all the JavaBridge files will be extracted.

 STEP 9 : Check the tomcat library files at xampp\tomcat\lib folder. For JavaBridge we must need the recommended jar file (Those files are highlighted).


If any thing is  missing you can download and located at lib folder.

commons-collections-3.2.1.jar
commons-beanutils-1.9.2.jar
commons-digester-2.1.jar
commons-logging-1.2.jar
groovy-all-1.5.5.jar
itext-2.1.7.jar

jasperreports-6.0.4.jar (or)
jasperreports.jar

mysql-connector-java.jar (or)
mysql-connector-java-5.1.37-bin.jar
  
STEP 10 : If everything is fine check the tomcat JavaBridge. (http://localhost:8080/JavaBridge)


STEP 11 : If we got the Javabridge Page, Run the PHP application (http://localhost/JavaBridge). You can get the Success message.

Good Luck !



   

Sunday, 17 April 2016

How to Configure the ZEND Framework to my localhost ?

Configure Zend Configuration with Nebeans editor.

Requirements : XAMPP, Apache, MySQL, Zend Framework library folder and Netbeans editor

Download and install the XAMPP, Apache & Mysql

Download Zend library from Zend website.

Download Netbeans from Netbeans website.

Instructions:

1) Download and unzip the zend folder. Rename(zf) and paste the floder in D:\zf

2) Install the Netbeans Editor

3) Add the path in php.ini  file

include_path = “.;D:\xampp\php\pear\;D:\zf\library;C:\Program Files\NetBeans 6.9.1\php\zend”

4) In Netbeans Editor

Go to Tools -> Options -> Php -> General(Command line : Php interpreter) D:\xampp\php\php.exe ->

Click Zend and browse (D:\zf\bin\zf.bat)

5)In My Computer

Right click on MyComputer -> Properties -> Advanced -> Environment variables -> Double click on path

and Add At last (;D:\zf\bin)

if there is any error try this way also D:\zf\bin\;D:\xampp\php\;

6) Create your own project in local host, then directly access the ZEND library.

MySQL alter query getting 'Row size too large' issue ? issue : #1118

issue : #1118 - Row size too large. The maximum row size for the database table type not consider the BLOB or TEXT data type, other than remaining database types total row size is below 65535. If it exceeds these size, it shows the below error
 
The total size of all fields in the database table is more than the limit 65535. So this reason you are getting this error.


How to get the sizes of the tables of a MySQL database?
SQL : SHOW table status from <mydatabasename>;



Based on the table status you can easily fixed this issue.

Saturday, 16 April 2016

Secure PHP Application Development Considerations.

For any Web application development ( PHP, Java or .Net), Security wise we must consider 2 major things.

  • First one is Secured Hosting
  • Second is Coding level standards & secured code

Application hosting is very important in any web application. Without any security in web hosting level, there is no meaning to hosting the application. So we carefully select the best hosting service providers.

So many things we consider the development of PHP web application.

1) Disable the PHP Error Reporting  in Production:

Ex: error_reporting(0);

If any Issues, Warning and Errors are displayed in the application, that error represents the folder path, file name & line number. Then public user easily identify the folder & file system of the application. This is also one of the source to attack the application. So use error_reporting(0); in production servers.

2)  Limit Restrictions

PHP authentication point of view, must follow the server hitting limitations.

Ex: Suppose an anonymous user login to the application with different passwords, In any of the scenario he was  succeed to authenticate the application.

In this way we restrict the anonymous user, with limited hitting  to the application. So easily restrict the login hackers.

3) MySQL Data Injecting

Data injection is very sensitive and common issue in any application. This is accruing through browser URL's or AJAX requests.

To prevent this injection, use sprintf(), prepared statements and Mysql Real Escape String methods.

4) Input Validation

In any PHP application forms, we know what kind of data you are expecting on input, based on that follow the client side and server side validations. Then easily protect the application against the attacks.

5)  XSS Attacks

To prevent this attacks, to filter the data with some predefined keywords.

 preg_match(), filter_var() and htmlspecialchars()

Generally these type of attacks are happens to executed with client side scripting. 



MySql Query Optimization Techniques and Good Practices

Several things need to follow at the time of creating the MySQL Tables and Query building.

1) In Select query don't  use the (*) asterisk symbol, instead of using the asterisk symbol  listed the database table column names. Why because select query follows the matrix mechanism at the time of retrieving data from the database table.

2) At the time of build the new Tables must follow the AUTO INCREMENT attribute. Here Auto Increment attribute consider, that column ID is primary key. Based on primary key easily perform the transactions.

3) Avoid to use "TEXT" and "BLOG" data types.

4) ORDER BY RAND() takes the much amount of time to retrieving the data. So try reduce the usage of RAND() attribute.

5) For good practice, table name columns use the  data type of the first character, Then easily identify, which datatype is the particular column at coding level.

Ex:

 iId - Represents the Integer Datatype Column
vTitle - Represents the  Varchar Datatype Column

6)  Don't use the much spaces for column size. We know what data we are passing that particular column, according to that we follow the datatype sizes.

Ex:
Country is the one of the column in our database. Here we need maximum 50 characters only. So we create  varchar country(50) its  enough.

7) Enumeration Data type is one of the most important fast retrieving technique. Instead of using the Integer we try to use enum datatype.

8) For any MySQL attribute , use the capital letters. It is also one of the good practice.

Ex:
SELECT,  INSERT, DELETE, FROM, OR, ORDER BY, LIMIT etc.

9) For single column data retrieving use the LIMIT 1. If we use this, looping is stopped, once that  particular column was detected.

Ex:
SELECT iId,vTitle FROM student WHERE iId = 1 LIMIT 0,1;