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: Convert Web Hex Color Code to RGB Array

Sometimes you need to RGB array that makes up a color when working in the wonderful world of PHP. Don’t ask me why or when, though that said, I have required it at least once before when setting text color whilst generating PDFs using the FPDF library – so I have at least established that you do sometimes want to do this Continue reading

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

PHP: Convert a RGB color Array into a Web Hex Code

RGB, that annoying little way of expressing a color via values between 0 and 255 for each of the three components that makes up a color. Always in the form of an array consisting of three values, namely one for red, one for green and one for blue, wouldn’t it be nice if we had a simple function that automatically converted such an array to the more universal web hex code? (Well when I say universal I mean developing on the web). Continue reading

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

FPDF: Failing to Insert a Google Chart into a PDF

My tried and trusted method for inserting graphs into PDFs is to use the nifty PHP FPDF library and insert an image into it via a Google Chart URL.
Continue reading

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

MySQL: Got a packet bigger than ‘max_allowed_packet’ bytes Error

I came across a nasty little bug in my image upload to MySQL blob in base 64 encode function the other day – basically the database was spitting back the following error to me: Error code: 1153 – Got a … Continue reading

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

PHP: Write to Text File

Just a simple code snippet to remind myself just how easy it is to spit out content into a text file using PHP. $myFile = “testFile.txt”; $fh = fopen($myFile, ‘w’) or die(“can’t open file”); fwrite($fh, “Text sentence for line 1\n”); … Continue reading

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