The Basics Of Avoiding MySQL Injection Attacks In ASP.NET Web Forms
Received in my email today:
Hi
say your blog and thought you might help.
strsql = “SELECT StaffID, DesignationID, StaffName, Password, ShopID from staffT where StaffName =” & UserName.Text & ” AND Password =” & Password.Text & “”
from the string, the username.text and password.text are form controls. what is happening is there are passing null values regardless of what you input in the text boxes resulting in a system error.
“System Error Object reference not set to an instance of an object”
Am using Mysql as the database.
I’m always glad to answer such questions, especially when the questioner is flirting with disaster, as much as this questioner is.
A trained eye can immediately spot the problem with the SQL statement above, aside from the problem of NULL values tossing errors. Namely, it’s wide-open to SQL injection. (And an even keener eye will note that the values for user name and password aren’t delimited with single-quotes.)
So here’s my reply email to the questioner:
Continue reading: The Basics Of Avoiding MySQL Injection Attacks In ASP.NET Web Forms »
Preloading Images With JavaScript

Anne Hathaway
Almost all those examples are stupid or just plain wrong. For that, you have my apologies, and I aim to rectify those mistakes with this post.
First, why would we want to preload an image? Simply put, we intend to show it later on our Web page — either as a result of a mouseover, or a click, or some other sort of Document Object Model (DOM) event.
For example, maybe we want to mouseover a series of thumbnails, and show a larger version of that image in the same place.
Rather than making the end user wait for a new image to load as a result of doing something on a Web page, it makes sense to load the image we intend to show in advance, so it will display almost instantaneously as a result of an event.
I’ll first show why two of my previous methods for preloading images are wrong or dumb, then describe two correct ways to preload images: via basic JavaScript and via jQuery.
The lovely Anne Hathaway will be our model.
Continue reading: Preloading Images With JavaScript »
Working With The authorize.net Server Integration Method (SIM) Payment Gateway, Part 1: Don’t Use JavaScript
I got an email a few days ago from a reader seeking help with the authorize.net Server Integration Method (SIM) credit card payment gateway.
Specifically, he was asking how he could use JavaScript to pass a calculated total to a PHP page that contains the SIM code.
- A customer chooses a series of options from some select lists, radio buttons and the like;
- the page calculates an order total;
- the end user hits a submit button;
- the results are posted to the SIM processing page, which acts as a “confirmation page”; and
- The customer presses another button, which takes him to authorize.net to provide payment info and actually charge the card.
You can see an approximation of what I’m talking about here: http://www.dougv.com/demo/js_form_values. The questioner’s form is similar to this approximation in function.
Automatically Hash Tagging Text With PHP And MySQL Part 2: Adding New Hash Tags To The Database Table
Yesterday I wrote a short script that will automatically tag a subject string with terms contained in a database table. Today, I’m going to alter that script, so that user-designated hash tags will be added to the database.
For example, suppose we have a hash tag database table that contains the terms winter, summer and sun. If we apply those to the opening line of Richard III, it looks like this:
Now is the #winter of our discontent made glorious #summer by this #sun of York; and all the clouds that lour'd upon our house in the deep bosom of the ocean buried.
But what if we decided we wanted to also hash tag clouds, now and in the future? We can certainly manually do so every time, but having a convenient way to add that text to the database would be quite helpful.
That’s what today’s script will do: Find all the words we have manually hashtagged in the subject string and add them to the database, if they are not in the database already and we confirm we want them added.
Continue reading: Automatically Hash Tagging Text With PHP And MySQL Part 2: Adding New Hash Tags To The Database Table »
Automatically Hash Tagging Text With PHP And MySQL
My recent work on the Google Reader to Twitter interface led me to recognize a serious shortcoming of such a basic system: A lack of support for hash tags.
For those unfamiliar with Twitter, hashtags are basically words proceeded by a hash mark (#). When a word is “tagged”, it becomes a hyperlink to content also containing that term.
Tagging isn’t unique to Twitter. It’s integral to WordPress, Tumblr and many other blogging platforms; Google uses tags (which they call “labels”) in most of their major applications, including GMail and Google Documents.
The reason is simple: People tend to organize information in terms of categories, so interrelating content by linking items that belong to the same categories to one another makes it easier on us to find and process that information.
So here’s a quick and easy script that lets you take keywords / tags / labels / categories / what have you from a MySQL table, run those terms over a string / subject text, and automatically tag that string with those terms.
(In a later tutorial, I will describe how to add new terms to the database.)
Continue reading: Automatically Hash Tagging Text With PHP And MySQL »



