Tag Archives: php

Reviewer plugin: php version may not be greater than 10 character

While trying to activate the “Reviewer” plugin by evoG, I encountered the following error: Thankfully, after a little looking around I found where the PHP version is passed to the activation routine. By manually specifying a short PHP version (< 10 char) I was finally able to active the plugin 🙂 Here are the relevant sections to edit: /wp-content/plugins/reviewer/admin/includes/class-license-page.php NOTE: I recommend backing up your file before editing. If you encounter an error like this, I hope these tips will

Online PHP code editors

Here are some rather interesting PHP code editors that run entirely online. They can be particularly helpful if you need to be able to develop from any machine anywhere (as long as you have an internet connection). 🙂 PHP Code Editorhttp://edit.orgapage.de/PHP Code Editor is a web based interface to edit your code. This way you can work on your project now matter where in the world you are, or on wich computer you are sitting at. PHP Code Editor works…

Count occurrences both greater than, less than, or equal in MySQL

  SELECT COUNT(recycled) AS “Total”, SUM(CASE WHEN recycled = 1 THEN 1 ELSE 0 END) AS “New”, SUM(CASE WHEN recycled > 1 THEN 1 ELSE 0 END) AS “Recycled” FROM (a SELECT phone_number, count(*) AS recycled, sale_date FROM ( SELECT DISTINCT * FROM ( SELECT customers.phone_number, customers.sale_date FROM customers INNER JOIN ( SELECT customers.phone_number FROM customers WHERE sale_date BETWEEN ‘2014-05-23’ AND ‘2014-05-30’) list on customers.phone_number = list.phone_number ORDER BY phone_number DESC, sale_date DESC ) AS multiple_sales ) AS sale_dates_analysis GROUP

Enable PHP error reporting on Turnkey LAMP Stack

Recently while using Turnkey Linux I had some PHP scripts that were totally blank. This was just a local test server and I had a pretty good idea there were some PHP errors so I enabled PHP error reporting. If you are on a production server you would probably NOT want to do this. However, if you are like me and just doing some testing, here are the steps to enable error reporting: PHP error reporting is disabled – won’t

Turnkey SSH tunnel for MySQL PHP access

Very useful examples at the Linux Journal: http://www.linuxjournal.com/content/creating-secure-tunnels-ssh and I finally found a connection specification that would work: root@lamp ~# mysql -h localhost -P 3308 -u root -psomepassword vlmdatabase ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysq ld.sock’ (2) root@lamp ~# mysql -h localhost -P 3308 -u root -psomepassword vlmdatabase ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysq ld.sock’ (2) root@lamp ~# mysql -h -P 3308 -u root -psomepassword vlmdatabase The last one

Data truncated for column ‘status’ at row 1 [SOLVED]

Recently I encountered the following error: Data truncated for column ‘status’ at row 1 This was specifically in a PHP based web hotel/reservations app that uses MySQL for the database backend. When trying to add a new dropdown option value of ‘departed’, the form submission would always fail with the aforementioned error. Thankfully, the solution was easy once I checked the table/field definitions. The column ‘status’ was of type enum and thus needed to have the ‘departed’ value specifically enumerated in

MySQL: Count the total occupancy rate for a time period (month)

Recently I encountered a somewhat interesting MySQL/PHP task: determine occupancy for a reservation system. This entailed determining how many reservation days fall within a particular month. It was not possible to simply determine each reservation length (datediff from/to) and sum them because some reservations started before the month in question and other reservations lasted until the month was over. Therefore, one solution is to get the reservation lengths then compare the start and end of the reservation to the start

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

Page 1 of 212