Preventing “500 Internal Server Error” for uploaded files on IIS PHP Sites

You may be getting “500 Internal Server Error” upon requesting a uploaded images of a wordpress / php website running on IIS7+ / Windows Server. This same error can be noted as url rewrite error on some debugging tools (developer tools) like chrome inspector. Also the same error can be noted as 500.50.

Nature of the Problem:

This is a very simple problem resulting because of the insufficient permission to read the requested file using the user which is running the PHP service on the windows server machine.


For WordPress website

  1. Navigate to your WordPress site physical location
  2. Go to Wp-Content directory
  3. Right-Click uploads directory / folder and select ‘Properties’
  4. Go to ‘Security’ tab
  5. Click Edit
  6. Select ‘IUSR’ under group or user names
  7. Select ‘Read & Execute’ under permissions for IUSR
  8. Click ‘Apply’ and ‘Ok’
Correct Permission -uploads directory of WordPress on IIS
Correct Permission -uploads directory of WordPress on IIS

For Regular PHP websites

Follow the same procedures as the WordPress website. Note that the directory you need to give the permission to the ‘IUSR’ is the temporary directory specified in your ‘php.ini’ configuration file.

Android flat button (xml) Tutorial

What is flat design?

Flat design is a minimalistic design approach that emphasizes usability. It features clean, open space, crisp edges, bright colors and two-dimensional/flat illustrations.

Benefits of flat design

Bright, contrasting colors make illustrations and buttons pop from backgrounds, easily grab attention, and guide the user’s eye. The purpose of minimalistic imagery also contributes to flat design’s functional character.


First we need to choose two colors: for normal state and pressed state. Usually that’s the same colors with different type of depth. Pressed state color will also be used as for bottom line of flat button normal state.

Create colors.xml file inside values folder and define two colors there:

    <color name="blue_pressed">@android:color/holo_blue_dark</color>
    <color name="blue_normal">@android:color/holo_blue_light</color>

We used two standard android holo colors:

<!-- A dark Holo shade of blue -->
<color name="holo_blue_dark">#ff0099cc</color>
<!-- A light Holo shade of blue -->
<color name="holo_blue_light">#ff33b5e5</color>


Now we need to create dimen.xml file inside values folder and define two parameters:

    <dimen name="corner_radius">4dp</dimen>
    <dimen name="layer_padding">3dp<<dimen>

Corner radius indicate how rounded the corners of our button will be. See image below.say-hello-android-flat-button-1


Layer radius indicate distance between bottom and top layer of our button. See image below.say-hello-android-flat-button-2


Next step is to define shapes for button background. Create rect_pressed.xml file inside drawable folder. This will be our pressed state background and bottom layer for normal state.

<shape xmlns:android=""
  <corners android:radius="@dimen/corner_radius" />
  <solid android:color="@color/blue_pressed" />


say-hello-android-flat-button-drawableFor normal state create rect_normal.xml file inside drawable folder. This drawable combines two layers, for bottom layer we used rect_pressed drawable and for top layer we defined new shape with little padding on the bottom (to make bottom layer visible) and new blue color.

<layer-list xmlns:android="">
  <item android:drawable="@drawable/rect_pressed" />
  <item android:bottom="@dimen/layer_padding">
      <shape android:shape="rectangle">
          <corners android:radius="@dimen/corner_radius" />
          <solid android:color="@color/blue_normal" />


Last thing to do is to define selector for our button. Create flat_selector.xml file inside drawablefolder.

<selector xmlns:android="">
  <item android:state_pressed="true" android:drawable="@drawable/rect_pressed"/>
  <item android:drawable="@drawable/rect_normal"/>

That’s all, now simply define your button and set background to flat_selector.

      android:text="Say Hello" />

Hope you enjoy this little article.

Interview Question : What is Synonyms in Database Engine?

A synonym is a database object that serves the following purposes:

  • Provides an alternative name for another database object, referred to as the base object, that can exist on a local or remote server.
  • Provides a layer of abstraction that protects a client application from changes made to the name or location of the base object.

For example, consider the Employee table of Adventure Works, located on a server named Server1. To reference this table from another server, Server2, a client application would have to use the four-part name Server1.AdventureWorks.Person.Employee. Also, if the location of the table were to change, for example, to another server, the client application would have to be modified to reflect that change.

To address both these issues, you can create a synonym, EmpTable, on Server2 for the Employee table on Server1. Now, the client application only has to use the single-part name, EmpTable, to reference the Employee table. Also, if the location of the Employee table changes, you will have to modify the synonym, EmpTable, to point to the new location of the Employee table. Because there is no ALTER SYNONYM statement, you first have to drop the synonym, EmpTable, and then re-create the synonym with the same name, but point the synonym to the new location of Employee.

A synonym cannot be the base object for another synonym, and a synonym cannot reference a user-defined aggregate function.

Various Build Actions in Visual Studio

Hello everyone, In this post we are going to learn about various Build Actions of Visual Studio. The Build Action property indicates what Visual Studio does with a file when a build is executed. 

Actually you can change build action of each and every file in any visual studio project. Each build action has its own functionality as described below:

  • None: The file is not included in the project output group and is not compiled in the build process. An example is a text file that contains documentation, such as a Readme file.
  • Compile: The file is compiled into the build output. This setting is used for code files.
  • Content: Allows you to retrieve a file (in same dir as assembly) as a stream via Application.GetContentStream( uri ). For this method to work, it needs a AssemblyAssociatedContentFile custom attribute which VS graciously adds when you mark a file as “Content”
  • Embedded resource: embeds the file in an exclusive assembly manifest resource.
  • Resource (wpf only): embeds the file in a shared (by all files in the assembly with similar setting) assembly manifest resource named AppName.g.resources.
  • Page (wpf only): Used to compile a xaml file into baml. The baml is then embedded with the same technique as Resource (i.e. available as `AppName.g.resources)
  • ApplicationDefinition (wpf only): Mark the XAML/class file that defines your application. You specify the code-behind with the x:Class=”Namespace.ClassName” and set the startup form/page with StartupUri=”Window1.xaml”
  • SplashScreen (wpf only): An image that is marked as SplashScreen is shown automatically when an WPF application loads, and then fades
  • DesignData: Compiles xaml viewmodels so that usercontrols can be previewed with sample data in visual studio (uses mock types)
  • DesignDataWithDesignTimeCreatableTypes: Compiles xaml viewmodels so that usercontrols can be previewed with sample data in visual studio (uses actual types)
  • EntityDeploy: (Entity Framework): used to deploy the Entity Framework artifacts
  • CodeAnalysisDictionary: A xml file containing custom word dictionary for spelling rules


Common Questions / Issues associated with understanding Build Action:

  1. My class under App_Code / App_Data is not accessible in Visual Studio .NET
  2. Cannot reference App_Code in .NET


The above questions mostly asked with the ASP.NET development, The answer is simple change the Build Action of the files under App_Data from Content to Compile.

If you have trouble to find build action, kindly follow the steps below.
  1. Select the file under App_Code / App_Data
  2. Go to Properties window
  3. Change Build Action to Compile

SQL Join Tables with Group By and Order By

In this post of easy lesson series, we are going to discuss the usage of GROUP BY and ORDER BY clause within a JOIN clause. First of all you need to know what is a sql join clause.

A SQL join clause combines records from two or more tables in a relational database. It creates a set that can be saved as a table or used as it is. A JOIN is a means for combining fields from two tables (or more) by using values common to each.

Sample table : agents

| A007       | john doe             | Bangalore          |       0.15 | 077-25814763    |         |
| A003       | Lawrence             | London             |       0.13 | 075-12458969    |         |
| A008       | Christlin            | New York           |       0.12 | 044-25874365    |         |
| A011       | Kowsik Prasanth      | Bangalore          |       0.15 | 077-45625874    |         |
| A010       | Jones Rajakumar      | Chennai            |       0.14 | 007-22388644    |         |
| A012       | Lucida               | San Jose           |       0.12 | 044-52981425    |         |
| A005       | Anderson             | Brisban            |       0.13 | 045-21447739    |         |
| A001       | Dinesh Kumar         | Bangalore          |       0.14 | 077-12346674    |         |
| A002       | Mukesh               | Mumbai             |       0.11 | 029-12358964    |         |
| A006       | McDen                | London             |       0.15 | 078-22255588    |         |
| A004       | Ivan                 | Torento            |       0.15 | 008-22544166    |         |
| A009       | Benjamin             | Hampshair          |       0.11 | 008-22536178    |         |

Sample table : orders

---------- ---------- -------------- --------- --------------- --------------- -----------------
    200114       3500           2000 15-AUG-08 C00002          A008
    200122       2500            400 16-SEP-08 C00003          A004
    200118        500            100 20-JUL-08 C00023          A006
    200119       4000            700 16-SEP-08 C00007          A010
    200121       1500            600 23-SEP-08 C00008          A004
    200130       2500            400 30-JUL-08 C00025          A011
    200134       4200           1800 25-SEP-08 C00004          A005
    200115       2000           1200 08-FEB-08 C00013          A013
    200108       4000            600 15-FEB-08 C00008          A004
    200103       1500            700 15-MAY-08 C00021          A005
    200105       2500            500 18-JUL-08 C00025          A011
    200109       3500            800 30-JUL-08 C00011          A010
    200101       3000           1000 15-JUL-08 C00001          A008
    200111       1000            300 10-JUL-08 C00020          A008
    200104       1500            500 13-MAR-08 C00006          A004
    200106       2500            700 20-APR-08 C00005          A002
    200125       2000            600 10-OCT-08 C00018          A005
    200117        800            200 20-OCT-08 C00014          A001
    200123        500            100 16-SEP-08 C00022          A002
    200120        500            100 20-JUL-08 C00009          A002
    200116        500            100 13-JUL-08 C00010          A009
    200124        500            100 20-JUN-08 C00017          A007
    200126        500            100 24-JUN-08 C00022          A002
    200129       2500            500 20-JUL-08 C00024          A006
    200127       2500            400 20-JUL-08 C00015          A003
    200128       3500           1500 20-JUL-08 C00009          A002
    200135       2000            800 16-SEP-08 C00007          A010
    200131        900            150 26-AUG-08 C00012          A012
    200133       1200            400 29-JUN-08 C00009          A002
    200132       4000           2000 15-AUG-08 C00013          A013
    200100       1000            600 08-JAN-08 C00015          A003
    200110       3000            500 15-APR-08 C00019          A010
    200107       4500            900 30-AUG-08 C00007          A010
    200112       2000            400 30-MAY-08 C00016          A007
    200113       4000            600 10-JUN-08 C00022          A002
    200102       2000            300 25-MAY-08 C00012          A012
To get ‘agent_code’ and ‘agent_name’ columns from the table ‘agents’ and sum of ‘advance_amount’ column from the table ‘orders’ after a joining, with following conditions –

1. ‘agent_code’ of ‘agents’ and ‘orders’ must be same,

2. the same combination of ‘agent_code’ and ‘agent_name’ of ‘agents’ table must be within a group,

3. ‘agent_code’ of ‘agents’ table should arrange in a order, default is ascending order,

the following sql statement can be used :

SELECT agents.agent_code,agents.agent_name, SUM(orders.advance_amount) FROM agents,orders  WHERE agents.agent_code=orders.agent_code GROUP BY agents.agent_code,agents.agent_name ORDER BY agents.agent_code;

the following sql statement is equivalent version of the above statement (see the JOIN keyword):

SELECT agents.agent_code,agents.agent_name, SUM(orders.advance_amount) FROM agents INNER JOIN orders ON orders.agent_code = agents.agent_code GROUP BY agents.agent_code,agents.agent_name ORDER BY agents.agent_code;

Above queries may look different but the working principles and output are the same. So both the queries will give the following output when you run them independently.

NOTE: The column name utilized by the ORDER BY clause should be contained in either an aggregate function or the GROUP BY clause.


---------- ---------------------------------------- --------------------------
A001       Dinesh Kumar                                                    200
A002       Mukesh                                                         3500
A003       Lawrence                                                       1000
A004       Ivan                                                           2100
A005       Anderson                                                       3100
A006       McDen                                                           600
A007       John Doe                                                        500
A008       Christlin                                                      3300
A009       Benjamin                                                        100
A010       Jones Rajakumar                                                3700
A011       Kowsik Prasanth                                                 900
A012       Lucida                                                          450

Interview Question : What is Thread?

Quad Core processor and Threads Winged Post

A thread is a single sequential flow of control within a program. the threads of a computer program allows the program to execute sequential actions or many actions at once. Each thread in a program identifies a process that runs when the program asks it to.

The term “Thread” can also be defined as

  1. a smallest unit of processing that can be scheduled by an Operating System.
  2. a portion of code that may be executed independently of the main program.
  3. an ordered sequence of instructions that tells the computer what to do
  4. In online discussion, a thread can refer to a series of related messages.
  5. In e-mail, a thread can refer to a series of replies back and forth pertaining a certain message.

Extended Information:

All programmers are familiar with writing sequential programs. You’ve probably written a program that displays “Hello World!” or sorts a list of names or computes a list of prime numbers. These are sequential programs. That is, each has a beginning, an execution sequence, and an end. At any given time during the runtime of the program, there is a single point of execution.

A thread is similar to the sequential programs described above. A single thread also has a beginning, a sequence, and an end. At any given time during the runtime of the thread, there is a single point of execution. However, a thread itself is not a program; a thread cannot run on its own. Rather, it runs within a program.

Some texts call a thread, a lightweight process. A thread is similar to a real process in that both have a single sequential flow of control. However, a thread is considered lightweight because it runs within the context of a full-blown program and takes advantage of the resources allocated for that program and the program’s environment.

Multiple threads can exists within the same process and share resources such as memory, while different processes do not share these resources.


Source / Courtesy : WiseGeek

Interview Question : What is Object Oriented Programming?

Object Oriented Programming Languages - Winged Post

Object Oriented Programming (OOP) is a type of programming in which programmers define not only the data type of a data structure, but also the types of operations (functions) that can be applied to the data structure. In this way, the data structure becomes an object that includes both data and functions. In addition, programmers can create relationships between one object and another. For example, objects can inherit characteristics from other objects.

The Object Oriented Programming can also be defined as:

1. A style of programming that focuses on using objects to design and build applications.

2. Object oriented programming (OOP) is a model of programming language that focuses on the use of objects instead of actions in order to carry out tasks. This involves taking an approach that is more mindful of data and less concerned with logic, which is more commonly the case in other programming paradigms.

3. Object-oriented programming (OOP) is a programming paradigm based on the concept of “objects”, which are data structures that contain data, in the form of fields, often known as attributes; and code, in the form of procedures, often known as methods.


For your information, the following are some additional concepts associated with the Object Oriented Programming:

  1. Encapsulation means that a group of related properties, methods, and other members are treated as a single unit or object.
  2. Inheritance describes the ability to create new classes based on an existing class.
  3. Polymorphism means that you can have multiple classes that can be used interchangeably, even though each class implements the same properties or methods in different ways.


Interview Question : Define Array.

multi dimentional array data structure Winged Post

Array is a data structure consisting of a collection of elements (values or variables), each identified by at least one array index or key. An array is stored so that the position of each element can be computed from its index tuple by a mathematical formula. The simplest type of data structure is a linear array, also called one-dimensional array.  We can also define a array as a container object which holds a fixed number of values of a single data type.

array data structure Winged Post

Arrays are among the oldest and most important data structures, and are used by almost every program. They are also used to implement many other data structures, such as lists and strings. They effectively exploit the addressing logic of computers. In most modern computers and many external storage devices, the memory is a one-dimensional array of words, whose indices are their addresses. Processors, especially vector processors, are often optimized for array operations.

Arrays are useful mostly because the element indices can be computed at run time. Among other things, this feature allows a single iterative statement to process arbitrarily many elements of an array. For that reason, the elements of an array data structure are required to have the same size and should use the same data representation.

The following are also the definitions of array in the area other than computer programming:

  • In general, an array is a number of items arranged in some specified way – for example, in a list or in a three-dimensional table.
  • In random access memory (RAM), an array is the arrangement of memory cells.
  • In data storage, an array (disk array) is a method for storing information on multiple devices. A disk array is a hardware element that contains a large group of hard disk drives (HDDs).

Interview Question: Difference between LinkedList vs ArrayList in Java?


LinkedList and ArrayList both implement List Interface but how they work internally is where the differences lies. Main difference between ArrayList and LinkedList is that ArrayList is implemented using re-sizable array while LinkedList is implemented using doubly LinkedList. ArrayList is more popular among Java programmer than LinkedList as there are few scenarios on which LinkedList is a suitable collection than ArrayList. In this article we will see some differences between LinkedList and ArrayList and try to find out when and where to use LinkedList over ArrayList.

difference between arraylist and linkedlist - WingedPostThe Differences:

  1. Since Array is an index based data-structure searching or getting element from Array with index is pretty fast. Array provides O(1) performance for get(index) method but remove is costly in ArrayList as you need to rearrange all elements. On the Other hand LinkedList doesn’t provide Random or index based access and you need to iterate over linked list to retrieve any element which is of order O(n).
  2. Insertions  are easy and fast in LinkedList as compared to ArrayList because there is no risk of resizing array and copying content to new array if array gets full which makes adding into ArrayList of O(n) in worst case, while adding is O(1) operation in LinkedList in Java. ArrayList also needs to update its index if you insert something anywhere except at the end of array.
  3. Removal is like insertions better in LinkedList than ArrayList.
  4. LinkedList has more memory overhead than ArrayList because in ArrayList each index only holds actual object (data) but in case of LinkedList each node holds both data and address of next  and previous node.


Consuming a WebService using LINQ

[dropcap]T[/dropcap]his article demonstrates how to query a Web Service’s public API using LINQ. For this article, I am using the Web Service located at GeoNames. Our code will query the CountryInfo webservice which accepts a Country Code and returns information like the country’s capital, population, currency and so on.
Check out the XML document returned from this service over here
Let us get started:


Step 1: Create a Console Application. To this application, add a class named ‘Country’ and ‘CountryInfo’. The CountryInfo class has the following definition:
class CountryInfo
    public string CountryName { get; set; }
    public long Population { get; set; }
    public string Capital { get; set; }
    public string CurrencyCode { get; set; }
    public float AreaSqKm { get; set; }
Step 2: The Country class contains a SearchCountry method that returns an IEnumerable<CountryInfo> as shown below:


class Country
    public IEnumerable<CountryInfo> SearchCountry(string countryCode)
        string uri = Uri.EscapeUriString(countryCode);
        string url = FormatUrl(uri);
        XDocument xdoc = XDocument.Load(url);
        IEnumerable<CountryInfo> results =
        from cntry in xdoc.Descendants(“country”)
        select new CountryInfo
            CountryName = cntry.Element(“countryName”).Value,
            Capital = cntry.Element(“capital”).Value,
            AreaSqKm = Convert.ToSingle(cntry.Element(“areaInSqKm”).Value),
            Population = Convert.ToInt64(cntry.Element(“population”).Value),
            CurrencyCode = cntry.Element(“currencyCode”).Value
        return results;
    string FormatUrl(string cCode)
        return “” +
            “country=” + cCode +
The code is pretty straightforward. We first create the url with the search string using our FormatUrlmethod. We then use the XDocument.Load to create an XML document from the url. The last step is to loop through the XML document, populate the CountryInfo object and return the results.


Step 3: The final step is to code the Main() method to retrieve and display the results from the WebService. Here’s how the Main() method looks
static void Main(string[] args)
    Country country = new Country();
    string cntryCode = “IN”;
    IEnumerable<CountryInfo> cntryInfo = country.SearchCountry(cntryCode);
    foreach (var c in cntryInfo)
        Console.WriteLine(“You searched for {0}. “ +
                        “The population of {0} is {1} and its capital is {2}. “ +
                        “The CurrencyCode for {0} is {3} and it’s area in Sq. Km is {4}”,
            c.CountryName, c.Population, c.Capital,
            c.CurrencyCode, c.AreaSqKm);


In the example above, we are passing in the country code ‘IN’ for India. We then loop through an object of IEnumberable<CountryInfo> and print the result on the console. The output looks similar to the following:


00130032015 Console Output


Well that was a simple example of how to query a webservice using LINQ. I hope you liked this article and I thank you for viewing it. The entire source code of this article can be downloaded here

[wpfilebase tag=file id=1 tpl=download-button /]