Tag Archives: php

Reverse order of individual items in a delimited string

Topic: Reversing the order of individual items in a string. Specifics: I had a date contained in a GET query string that was formatted as follows: 01/27/2013 and I needed it reversed to 2013/01/27 Here is a simple method to do the reversing in PHP: $toDate = htmlentities($_GET[‘to’]); $toDateNew = implode(“/”,(array_reverse(explode(“/”,$toDate)))); Explanation of code: First you explode the $toDate variable, then reverse the resulting array, finally you implode that array back into a string. Of course there are other date

Set your own date format in MySQL

Use DATE_FORMAT in MySQL to create your date strings formatted however you like: SELECT CONCAT(YEAR(res_hotel_booking_bookings.created),’-‘,DATE_FORMAT(res_hotel_booking_bookings.created,’%m’) ,’-‘,DATE_FORMAT(res_hotel_booking_bookings.created,’%d’)) AS creationDate, Count(res_hotel_booking_bookings.id) As reservationsMade FROM res_hotel_booking_bookings WHERE res_hotel_booking_bookings.created >= ‘2013-10-15 00:00:00’ AND res_hotel_booking_bookings.created <= ‘2013-10-17 24:00:00’ GROUP BY YEAR(res_hotel_booking_bookings.created), MONTH(res_hotel_booking_bookings.created), DAY(res_hotel_booking_bookings.created) ORDER BY creationDate DESC There are more concise ways to do this, but this was adapted from an earlier method that used CONCAT so I stuck with that… 🙂

Changing the php file upload limit in Funtu Linux

To increase the PHP upload limit on a Funtoo based server, I needed to adjust these two settings in php.ini: php_value upload_max_filesize 15M php_value post_max_size 15M More related resources: upload – Changing upload_max_filesize on PHP – Stack Overflowhttp://stackoverflow.com/questions/1122418/changing-upload-max-filesize-on-php<?php ini_set(‘upload_max_filesize’, ’10M’); echo ini_get(‘upload_max_filesize’), “, ” , ini_get(‘post_max_size’) I end up with: Changing the php file upload limit in Ubuntu Linux | miscellaneous.debrishttp://www.miscdebris.net/blog/2008/04/14/changing-the-php-file-upload-limit-in-ubuntu-linux/sudo nano /etc/php5/apache2/php.ini search for “upload_max_filesize” with Ctrl-W and change “2M” to “20M”. Save the file with Ctrl-O and exit…

How to fix Customized Recent Comments duplicate comments

Customized Recent Comments is a great plugin for displaying recent comments on your WordPress blog. It has all the features I need and requires minimal install and setup. With most ‘recent comments’ plugins/widgets, if you (the blog owner) respond to a bunch of comments at once, you end up having your comments take up the entire recent comments listing 🙁 Thankfully, one of my favorite features of the plugin is its ability to exclude particular commenters from being listed. 🙂 However, the only issue I have

Make Windows 7 fulltext search PHP documents

Recently while trying to find the PHP file that I needed to edit, I was once again frustrated by Windows seeming inability to search the text contained in PHP files 🙁 Windows obviously has the capability to do file content searches since it does so for .txt files. Finally I got fed up with it and decided to find out how to enable full text searching of .php documents. Here is what worked for me, I hope you will find

Building a random name generator

Last night I had fun building a  little random name generator for my friend Adam and my wife. They both write and sometimes it is difficult to come up with names for characters, that is where the new tool comes in handy: Character Name Generator Every time you refresh the page you get a new name 🙂 I used to code a lot of fun little projects like this but lately I have not made time for it. I do

Fixing Warning: date() [function.date] in PHP 5.3 [solved]

If you recently upgraded to a newer version of PHP, like PHP 5.3, you may be getting some errors similar to this in your PHP scripts: Warning: date() [function.date]: It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘America/Chicago’ for […]  instead

Work links: slider selects and fuzzy queries

I’m working on a new project, here are some links that have been helpful to me… Overview of slider techniques: Javascript/Ajax Techniques for Sliders – Noupe http://www.noupe.com/javascript/30-javascriptajax-techniques-for-sliders-scrollers-and-scrollbars.htmlIn this article we’d like to present a list of hand-picked Slider techniques you can use to achieve some special visual effects in your designs… Specific slider examples: jQuery UI Slider from a Select Element – now with ARIA Support http://www.filamentgroup.com/lab/update_jquery_ui_slider_from_a_select_element_now_with_aria_support// selectToUISlider plugin uses progressive enhancement to scrape the data from a select element