Script Storage Update


This is an update to a previous post. In another post on this site, it was said that Dropbox Paper is the code storage of choice. This has changed. As of today, I much prefer using Microsoft’s GIT code repository known as: devops.azure.com. The benefits are numerous. Ability to revert back to previous versions Ability […]

Script Storage


Update here: Script Storage Update Throughout my career, my scripts have been a vital piece of my work. Where I store them has changed over the years. The challenge has been in finding a repository that is reliable, searchable, accessible from where I work, and that looks good with color-coding. Additionally, I don’t want to pay […]

PHP Regular Expressions – Remove Comments From SQL Text


This short block of PHP code takes a SQL script and removes the “dash-dash” and “/**/” comments from it.  Of course, many languages, including PHP itself, use the “/**/” comment style so this could apply to PHP scripts, as well. The line that removes the dash-dash style comments could easily be changed to the “//” […]

PHP Date Difference


Finding a quick PHP function for date difference was painful.  Now that I found it, here’s the quick easy way. This site was a great help: http://www.phpf1.com/tutorial/php-date-difference.html [code] function dateDiff($date_to_check,$unit=’d’){ $now = time(); $then = mktime(0,0,0,date(‘m’,$date_to_check),date(‘d’,$date_to_check),date(‘Y’,$date_to_check)); $diff = $now – $then; switch($unit){ case ‘d’: $fullDays = floor($diff/(60*60*24)); $output = $fullDays; break; case ‘h’: $fullDays = […]

PHP Regular Expressions – Remove Comments From SQL Text


This short block of PHP code takes a SQL script and removes the “dash-dash” and “/**/” comments from it.  Of course, many languages, including PHP itself, use the “/**/” comment style so this could apply to PHP scripts, as well.

Basic PHP Data Setup


Ideally, when setting up a data-driven PHP site, you should have your configuration and database connection code separate from your code that generates content.  What I want to display is a simple way to keep things separate and simple to work with. I use a config/index/data file structure.  There are ways to further break apart […]

HTML Checkboxes


Occasionally, you discover something that you have been doing wrong for a long time.  Sometimes it wasn’t something outright wrong but was just stupid.  That is what happened to me. When using an HTML checkbox, it “POSTS” to the form submit page with the value of “on”.  I have always converted that on the page […]

PHP and jQuery – Reduce Long String to Preview Length and Reveal Full Text OnClick


Goal: Reduce long string to specified length for end-user preview.  Reveal entire string when clicked.  Go back to preview when clicked again. See Example Step 1: PHP Code [code] static function ReduceStringForPreview($text,$size=100) { define($reduced,”); if(strlen($text) > $size) { $reduced .= ” “. substr($text, 0, $size); $remaining = substr($text, $size); $reduced .= “…$remaining “; $text = […]

JSON Returning NULL When Special Characters Exist in Result Set


Nearly 24 hours of my life lost and I just figured this out. Maybe I can save someone else some precious time. Overview of JSON (skip this if you know what JSON is) When sending information from JavaScript via AJAX to a PHP server, certain things don’t transfer because you are dealing with different programming […]