Daily Archives: January 4, 2011

SQL Injection — How to sanitize your user forms.

SQL injection… I hate this. I’ve been a victim of this once and it caused me a lot of work… (not too much, I just restored the database from the previous day). Anyway, since then I always use my general … Continue reading

Posted in Uncategorized | Comments Off on SQL Injection — How to sanitize your user forms.

How to check for EOF in MySQL

In ASP, I can check for an End-Of-File condition by using rs.EOF     ‘ returns True or False For example, if I’m verifying if a certain UserName exists in the database, I can do a SELECT * FROM query, and check … Continue reading

Posted in sql | Comments Off on How to check for EOF in MySQL

My first “real” PHP program! User Registration

I think I just created my first “real” PHP program. It’s a User Registration Form which does the following: checks if username entered is at least 4 char long the email address entered is valid format (but no checking if … Continue reading

Posted in Uncategorized | Comments Off on My first “real” PHP program! User Registration

MySQL $query format

In MySQL, you can create your query string like this: $query = “INSERT INTO NameDB (field1, field2, ….) VALUES (‘$value1’, ‘$value2’,….)”; Note that $values must be enclosed in quotes, otherwise you get an SQL error. In a way, this is … Continue reading

Posted in Uncategorized | Comments Off on MySQL $query format

Move to first record of table

In ASP, we use rs.MoveFirst In PHP, we need to use: // go back to top mysql_data_seek($result, 0);        // first row number is 0

Posted in Uncategorized | Comments Off on Move to first record of table

Detect if a form is submitted

If a form has not been submitted yet, you’ll get an error message if you try to get the values of the form. (Unlike in ASP, which just returns an empty string.) To detect if a user form has been … Continue reading

Posted in Uncategorized | Comments Off on Detect if a form is submitted