Some regular expressions and how to use them in PHP

Thursday, July 28, 2011 | En Español

This isn't a guide about how to create regular expressions (although I would like to make one). These are a few regular expression that I made some time ago, when I had access to a list of names, addresses, phone numbers, etc. They were formatted in very different ways (special the phone numbers) so, the simpler regular expressions that I was using before that, had to be improved. I also talk about to use this regular expressions to validate input fields in PHP scripts.

Read more...

Categories: PHP, Programming

Prepared MySQL statements in PHP (object oriented examples)

Tuesday, July 12, 2011 | En Español

I find sad how many online systems are out there unprotected against even the simplest type of attack, SQL injections. This is a guide and a set of examples about the use of prepared MySQL statements in PHP. If you want to see how an SQL injection attack works you can read the previous article An SQL injection attack. There is a similar guide to this but using the regular structured functions from the MysqlI library at Prepared MySQL statements in PHP (structured examples).

Read more...

Categories: MySQL, PHP, Programming

Prepared MySQL statements in PHP (structured examples)

Tuesday, July 12, 2011 | En Español

I find sad how many online systems are out there unprotected against even the simplest type of attack, SQL injections. This is a guide and a set of examples about the use of prepared MySQL statements in PHP. If you want to see how an SQL injection attack works you can read the previous article An SQL injection attack. There is a similar guide to this but using the object oriented interface of MysqlI in the examples at Prepared MySQL statements in PHP (object oriented examples).

Read more...

Categories: MySQL, PHP, Programming

An SQL injection attack

Tuesday, July 12, 2011 | En Español

Since I wrote two different guides about the use of prepared MySQL statements in PHP, and one of the reasons for use this is to prevent SQL injection attacks, I am going to write a little about these attacks that many websites has suffer and continue to suffer even today. More than define what this attack is, the objective is to show how it works.

Read more...

Categories: MySQL, PHP, Programming

My most used htaccess settings

Sunday, November 07, 2010 | En Español

The file .htaccess allows us to change some of the settings of a server for a particular directory and it's subdirectories. While it is preferable to make this type of configurations in the server configuration file itself by the use of a <Directory> section, sometimes we simply don't have access to this configuration file, specially when we have a shared hosting account. Most shared hosting providers allows us to make changes to the behavior of the server only in this way.

Read more...

Categories: Apache, FOSS, PHP

How to create cropped and scaled thumbnails in PHP

Tuesday, September 28, 2010 | En Español

In the previous post, we created scaled thumbnails of images that maintained their aspect ratio. In this post we will see how to crop and scale the image to fill the thumbnail area.

Read more...

Categories: PHP, Programming

How to create scaled thumbnails in PHP

Tuesday, September 28, 2010 | En Español

It's always a good idea to generate as many different sizes of thumbnails as are required in a web based system, right after an image is uploaded. Some of the advantages of generating and storing the thumbnails are that you can reduce the processing time that your server needs to use if you generate the thumbnails on demand, and of course you can reduce the consumed bandwidth by not sending the full size image when this is not necessary.

Read more...

Categories: PHP, Programming

Working with UTF-8 in PHP, MySQL and Apache

Wednesday, September 15, 2010 | En Español

As I have previously posted in this website, I believe it is a good idea to standardize in one character encoding across all parts of a system, and as my preferred character encoding is UTF-8, when I create a PHP system I check the following things:

  • That the browser receives and interprets the output of my PHP scripts as UTF-8.
  • That the (X)HTML forms accept UTF-8.
  • That PHP treats the data received from a MySQL database as UTF-8.

Read more...

Categories: (X)HTML, Apache, FOSS, MySQL, PHP