Category Archives: Technology & Code

Technology, gadgetry and code are just plain awesome, you can’t really deny it. So when I come across something that excites me or makes my life easier or simply gives us a view as to a very possible future that we might be moving towards, I can’t help but share it with the rest of you here on the CodeUnit of Craig.

PHP: File Upload Error Code

When handling file uploads via enctype=”multipart/form-data” forms in PHP, you’ll be pleased to know that PHP doesn’t just leave you high and dry but instead returns some pretty helpful error codes to let you know when something goes wrong. Continue reading

Posted in Technology & Code | Tagged , , , | 2 Comments

PHP: Strtotime and Handling Different Date Formats

Strtotime is a powerful date manipulating ally of any PHP developer, but unfortunately it doesn’t really respond to locale settings all that well, meaning that should you not be an American, in other words your dates don’t look like the silly MM/DD/YYYY format, it can return some rather strange and unexpected results! Continue reading

Posted in Technology & Code, Tutorials | Tagged , , , | Leave a comment

PHP: Page Redirecting with Header… and Die()

I make use of PHP’s handy header function to handle simple page redirects for me, perhaps a bit of a cheap way of doing it, but one that is remarkable effective. Sure, you need to change the way you code a little and perhaps introduce some ob_start and ob_end_flush calls if necessary, but on the whole a good old header(‘Location: newpage.htm’) call works pretty damn well. Continue reading

Posted in Technology & Code, Tutorials | Tagged , , , , , | Leave a comment

jQuery: Change the Selected Index of a Dropdown List

To change the selected value, or selected index if you will, of a dropdown list using jQuery is not particularly difficult. Continue reading

Posted in Technology & Code, Tutorials | Tagged , , , , | 5 Comments

PHP: Random Color Generator Function

Although I’ve posted simple random color generating code snippets before, I’ve noticed since that most of them have a flaw in that they sometimes don’t always produce a proper six character long hex color code. Continue reading

Posted in Technology & Code, Tutorials | Tagged , , , | 3 Comments