Archive for category php-mysql

Cache PHP to gzipped static html pages using htaccess redirect

No matter the server performance, the fastest kind of website for a visitor is the one with static HTML pages; this way the server just has to upload existing data to the browser instead of starting the PHP compiler, open a connection to MySQL, fetch data, format the page and only after that send it. […]

Tags: , , , ,

Zip MySQL database backup with PHP and send as email attachment

I was a happy user of MySQLDumper until a while ago, when my shared hosting upgraded to the cloud architecture and latest PHP version; with that, some modules for PERL went missing and I was left without a viable backup solution (MySQLDumper PHP approach uses a javascript reloading routine which is superslow and is not […]

Tags: , , , ,

MySQL query with ORDER BY,GROUP BY to remove duplicate rows after ordering

Apparently this is a widely discussed issue with MySQL; many newbies (like me) wanting to SELECT rows from a table, where they know there are duplicates of some field ‘a’ which they want unique, but making sure that the selected row has the field ‘b’ with the lower, highest, longest or shortest (whatever) value among […]

Tags: , , ,

Inverted search in MySQL database: check if keywords in field match some text

Usually, “searching a database” means looking for rows that contain a “document” in a field that matches a certain keywords set (mostly using the MATCH AGAINST construct); let’s say you want to do the opposite instead, that is finding those rows that have a field containing keywords, or a phrase, that matches to a text […]

Tags: , ,

MySQL SELECT query with more WHERE conditions runs faster

For some reason I wanted to add more redundant conditions to a WHERE clause in a MySQL SELECT query, but I feared that, being redundant conditions, I may end up slowing up the query. Shortly, there is this classifieds site, where each item’s table has the town_id, province_id and region_id rows. If you know the […]

Tags: , ,

PHP search string functions performance is “needle” dependent

I was playing with some templating benchmarks in my post before this one, and bumped into an interesting find regarding the way strpos works, and consequently all similar “search (and replace)” functions like str_replace, strrpos, stripos, str_ireplace, substr_replace, even preg_match and preg_replace (I tested only str_replace and preg_match out of these, but I assume they […]

Tags: , , ,

PHP templating, preg_match, file_get_contents and strpos, the fastest

While working on the website of reecycle.it, il frecycling italiano per il riciclo degli oggetti, I am spending my resources also on reducing at most the load on the Apache server of my italian shared hosting, Tophost, so i decided to make some benchmarks to see which was the best speed I could load the […]

Tags: , ,

(Italiano) Tophost e variabile di sessione “user” riservata in PHP

Sorry, this entry is only available in Italiano.

Tags: ,

PunBB e-mail notification on each new post extension

On another site I manage, I just switched from the previous forum script to PunBB; one feature I missed after the switch is the ability to activate an email notification for each and every post the users add into the forum, so I had to write my own. Following is the source code of the […]

Tags:

How to fix Fatal error: Allowed memory size exhausted in WordPress 3

This error is nothing new, per se, as far as I know it was present also in previous versions of wordpress (I’m a fresh new user and I’ve been using v3+ for more than I’ve been with 2.9.7 (first one I installed). When this error occurred in previous versions, all you needed to do was […]

Tags: ,