PHP

2 + Me = Team

I have asked 2 friends to learn to make dynamic web applications to assist me in future projects. Hopefully inside of 6 months, they will have a productive understanding of the following:

  • PHP
  • MySQL
  • Apache
  • CSS
  • XHTML
  • Javascript
  • XML
  • AJAX
  • Flash
  • PHP Extensions: curl, soap, gd.

Once they are comfortable with at least the top half of the list, they will become valuable to the team effort, and can assist in making my dreams of code become reality of income. All while allowing me to also keep my pink mohawk for a very, very, very long time.

VN:F [1.9.7_1111]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.7_1111]
Rating: 0 (from 0 votes)

Sometimes a misplaced } can be lost for 2 days.

While trying to make a php file that will be cron processed daily to read some CSV files, I decided to merge all csv file information into a database and control it all in one php file instead of one php file per CSV. After getting things working, I accidentally placed a while / do loop ending “}” in the wrong location and didn’t realize that it was the problem for 2 days. The database connection was being closed and the information was no longer being inserted into the database, all because of one misplaced “}”.

Now that I found the problem, fixed it, and uploaded the new code now I can include more CSV files in about 5 minutes instead of 2 hours or more.

I just wish all the companies sending the CSV files for the client would stick to the same format instead of being completely and utterly different from company to company. No structure means I have to have unneeded troubles trying to keep everything sane and sanity in the database.

If I were Google, they would listen to me and send the data in one uniform format. Alas, I am just me, so they do as they please.

VN:F [1.9.7_1111]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.7_1111]
Rating: 0 (from 0 votes)

PHP Example: Scrub Credit Card Numbers For Security Purposes When Storing In Your Database.

Processing credit card orders online and storing them can be dangerous, not just for the customers, but also for your own reputation. With the sample code I’ve written for you from my own recent programming tasks, you will see how to take the incoming credit card number and scrub it clean so that only the last 4 digits will be shown when stored in your database.

Example credit card number:
4111111111111111 (Sample VISA number)

// Get length of credit card numbers (Usually 15 or 16 digits).
$scrub_length	= strlen($_POST['cc_number']);
// Find last four digits.
$scrub_last_4	= substr($_POST['cc_number'], $scrub_length-4, 4);
// Pad all numbers with an * except for the last 4 digits.
$scrub_pad	= str_pad($scrub_last_4, $scrub_length, "*", STR_PAD_LEFT);
// New scrubbed credit card number is the padded string.
$scrub_cc_number = $scrub_pad;

This is the final string that will be output:
************1111

Now insert the scrubbed credit card number into your database without worries of it being stolen and used by malicious intruders.

@mysql_query("INSERT  INTO `payments` (`cc_number`) VALUES('".$scrub_cc_number."')");

It’s fairly easy, not much to it.

Enjoy,

- Xeon

VN:F [1.9.7_1111]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.7_1111]
Rating: 0 (from 0 votes)