Tech Thought

Tech tips, hints, and general musings. PHP, Perl, Mysql, Javascript, AJAX, JSON, Linux, Mac OSX

Entries for January 15th, 2008

Mysql: Defaulting a DATE field to current date

I recently came across the Mysql TIMESTAMP field type.  I’ve seen this datatype for years, however have never really used it – until now.  I’ve been looking for a way to set a fields value to the current date/time by default.  You can’t do this with DATETIME field types in mysql, however you can do [...]

Leave a Comment

Problem with PHP json_decode() and prototype.js .toJSON() function

I have been tearing my hair out trying to work out why PHP’s json_decode() function wouldn’t convert a JSON string sent via AJAX using the prototype.js .toJSON() function. I was sending the string: {\”Assembly_ID\”: 1} However json_decode() in php would return NULL. After some fiddling around, I determined that json_decode() doesn’t like the “\” characters. [...]

Comments (3)

Data::Dumper for PHP

Along the same lines of my previous post, I was looking for a PHP equivalent to Data::Dumper for Perl. Php has a builtin function called var_dump() which will give you some fairly ugly output about your array/hash/object, however I was looking for something a little more elegant.Thankfully the folks over at Pear have come up [...]

Leave a Comment

Equivalent to Perl’s ‘chop()’ function for php

I’ve been writing Perl code since just after I learned to walk, so I’m always looking for ways to do things in a Perl-ish manner. My latest requirement was an equivalent to the perl chop() command to remove the last character of a string for PHP. After a bit of searching around, it appears the [...]

Leave a Comment