TroyGrosfield.com TroyGrosfield.com

Archive for December, 2010

Headline

Parsing XML with Python using ElementTree

Author
by Troy Grosfield
Date
December 18th, 2010
Category
Developer
Story

There are many ways to parse XML in python. I will show you the basics on how to parse XML using ElementTree. While ElementTree 1.3 and higher is not needed for this example, it’s nice to have because it has better xpath support than the earlier version.  pip install elementtree if you don’t already have … read more

Tags
Comments
5 Comments »
Headline

Installing easy_install and pip for Python

Author
by Troy Grosfield
Date
December 18th, 2010
Category
Developer
Story

easy_install and pip are python package installers that will make your life a lot easier when developing in python. Installation These steps assume you already have python installed and that python is in your windows environment variables. Download setup-tools according to your python version.  I’m currently running python 2.7 and running on windows so I … read more

Tags
Comments
No Comments »
Headline

Preventing an SQL Injection Attack in PHP

Author
by Troy Grosfield
Date
December 15th, 2010
Category
Developer
Story

I recently was asked to fix some bugs on a particular website.  While looking through the state of the code I noticed the site was susceptible to an SQL injection attack. Issue The site is taking the user input and directly inserting it into the SQL statement without escaping. PHP Code Issue $sql = “SELECT … read more

Tags
Comments
No Comments »
Headline

Preventing Character Input Using Javascript

Author
by Troy Grosfield
Date
December 1st, 2010
Category
Developer
Story

The objective here is to prevent a user from typing a specific character in a textbox. This can be accomplished with only a few lines of Javascript. Html Here we create a simple form with a single textbox: <form action=”#”> <input type=”text” /> </form> Javascript Now we add the Javascript to prevent characters from being … read more

Tags
Comments
2 Comments »