Blogs
Error message
Deprecated function: Function create_function() is deprecated in GeSHi->_optimize_regexp_list_tokens_to_string() (line 4698 of /home/digipiph/public_html/sites/all/libraries/geshi/geshi.php).
published by d.cochran on Fri, 10/09/2015 - 12:27
Throughout my years in programming I've dealt a lot with reading and importing CSV files, exporting queries into CSV files, and building dynamic CSV files. I decided it was time to create a simple PHP class to do all this work for me.
With this class you can change the terminator, separator, enclosed, and escaped characters as well as mime type. You decide the file name and there are simple built in functions to let you easily navigate the rows and columns of the CSV.
The class is compatible with newer AND older (less than 5.3.0) versions of PHP.
published by d.cochran on Thu, 03/05/2015 - 08:38
A problem I run into all the time is how to use the equivalent of PHP's "continue" function with jQuery's "each" function. So I guess it is time to document it.
We can break jQuery's $.each() loop at a particular iteration by making the callback function return "false". If we return "true", it is the same as a continue statement in a for loop; it will skip immediately to the next iteration.
For example:
published by d.cochran on Fri, 07/11/2014 - 09:58
Multidimensional arrays are very handy for storing lots of data in one array variable opposed to creating and having to manage many individual array variables. For example, let's say we need to store all of our employee's data. Instead of creating many different arrays, one for each employee, we can simply create a multidimensional array, and store all of the employee's data within that.
Multidimensional Array that we will sort
published by d.cochran on Fri, 01/17/2014 - 09:57
There are many different ways to get the values of checkboxes using javascript or jQuery. I have assembled a list of some of the most popular methods.
Getting Radio Value using Name Attribute and jQuery
This method uses jQuery to select the DOM object via the name and property selector.
published by d.cochran on Fri, 10/18/2013 - 08:15
Here is an easy way to kill queries using PDO connection method with MySQL. Note that you can NOT kill queries using a "prepared" string. It must be done using "query".
The first step is to grab the PROCESSLIST.
published by d.cochran on Fri, 10/18/2013 - 08:00
Here are some PDO connection method basics with examples.
You will often commonly see the connection method being referred to as $dbh and $sth. These simply stand for "database handler" and "statement handler".
Connecting to MySQL with PDO Object
published by d.cochran on Sat, 08/24/2013 - 15:37
I wrote a simple PHP class that may be used for uploading and deleting files or images. This code allows the programmer to set the destination, file name, required extension, and max file size. The PHP class checks the file validation with its own internal functions and stores the errors or will automatically print the errors on screen if that is how you want them handled.
PHP Simple File Manager
published by d.cochran on Wed, 08/14/2013 - 08:04
It is possible to submit files using "multipart/form-data" and ajax. There are many sites out there that show complicated ways of doing this when it is really easy. It simply requires a little configuration of the jquery ajax process and grabbing your form data using the FormData() function.
Using the following method, you can submit multiple files and are not just limited to one.
Lets take a look at our form.
published by d.cochran on Mon, 01/14/2013 - 09:07
The below example shows how to return the difference in tables from a MySQL query
Problem: A user has the ability to assign labels to records. When a user is to add a new label to a record only query the labels the user has access to and don't display the labels already assigned.
published by d.cochran on Wed, 11/07/2012 - 07:54
Here is a quick example at how to build to an existing javascript name space. It is also used at building dynamic namespaces.
Pages