Tag Archives: php

How to fix the fatal error allowed memory size exhausted [SOLVED] (PHP)

How to fix the following memory size error on turnkeylinux (or similar)? ( ! ) Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 80 bytes) in /var/www/fit2019/index.php on line 2841 Call Stack # Time Memory Function Location 1 0.0015 510656 {main}( ) ../index.php:0 2 0.0153 523256 funcMakeTableTotal2019( ) ../index.php:487 3 2.0429 33543952 mssql_fetch_assoc ( ) ../index.php:2841 Answer:Edit the configuration file: /etc/php5/apache2/php.ini and set the memory limit to a value higher than 32M: memory_limit = 128M Then

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). 🙂 Online Code Editor – Codeanywherehttps://codeanywhere.net/Codeanywhere is compatible on all major browsers so you can work from the one you like, also if you on your mobile you can download the native mobile apps for iOS and Andriod. PhpFiddle – PHP/MySQL online IDE and execution

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 127.0.0.1 -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