July 18, 2011
The title may be a bit confusing, but recent I have come to need a function that retrieves the latest items from my database object arrays in one of my PHP project. I have three object arrays obtained using the
mysql_fetch_objectfunction, and I needed to get the latest items based on the timestamp they were posted. Before you tell me I should have used better SQL queries, I should mention that the MySQL tables have different data structures, but with the same column names.
I googled around hoping that there would be some simple solution to my needs – a function that will retrieve a preset number of items based on a condition from an array and output them as a new array. But the search was taking too long and Google was showing me too many irrelevant results. This prompted me to write my own solution, as usual.Read more »
April 23, 2011
I am currently working on a small project that requires me to use Apache on a Linux server. Since I am more accustomed to Ubuntu, I decided to install Ubuntu 10.10 on one of my virtual machines. So I installed everything I needed like Apache, MySQL and PHP5. Unfortunately, when I ran my PHP script, I hit a small problem. I kept getting an error 500 and it turned out that apparently the function imageantialias was not available in the PHP installation on my server.
After a bit of research, it turned out that the GD package used in Ubuntu is different to that used in other Linux distros. I looked around for a viable solution and finally discovered that the best way to overcome this problem was to compile PHP5 from source. Here’s how I did it.Read more »
February 17, 2011
Recently, I’ve been working on a small service application that monitors the IIS7 server for calls to have the server restart or shutdown. The reasoning behind using a service instead of having PHP restart or shutdown the server was that PHP does not run as a user with restart/shutdown privileges. So, it became a necessity to have a service that monitors for any shutdown calls from PHP.
I created a small service application using Embarcadero’s RAD Studio 2010 that runs as a service and checks for shutdown calls, as well as other processes. However, coming from Codegear, there were a few issues when importing an old application to be used as a base for the new application. Even after correcting all the paths that needed correction, I was getting this one error that prevented me from compiling the application.Read more »
January 21, 2011
I hit a snag when uploading large files using PHP on IIS 7.5. I was getting some weird Error 404, which in most cases means the PHP script that handles the upload process was not found. I checked my server, and sure enough, the PHP script was there. I tried again to be sure, this time with a smaller file. And what do you know, it worked just fine.
This led me to believe that there was a file size restriction imposed somewhere. I’ve already modified the php.ini file to allow me to upload larger files, but still no go. So the only other thing I can think of was IIS. Apache has something like that, so it’s only obvious that the ever-so-cautious IIS would be the same.
After much research, and a couple of Google searches later, I found a simple solution involving some simple config file edits. Damn, after working with IIS for the past 6 months, I got used to not having to deal with config files. Anyway, the file you want to modify is
C:\Windows\System32\inetsrv\config\applicationHost.config. I don’t know if it makes any difference, but I’ve converted the folders that hold my PHP scripts into Applications through the IIS Manager.
So open that file up using any text editor. It was a newly installed virtual server, so I didn’t have anything other than Notepad available.Read more »
January 14, 2011
I’ve been working with PHP to handle the server-side programming for a C++ application I am currently working on at work. Being a Japanese firm, it’s obvious our clients are also Japanese, thus working with Japanese file names also being obvious.
However, lately I’ve been having problems with PHP not being able to create a handler for folders with Japanese names. PHP’s DirectoryIterator gave me an error, and opendir just fails completely. This only happens with certain Japanese characters, like the Katakana for the letter ‘ソ’ and the kanji ‘表’. Upon further research, I’ve discovered that there is a possibility that PHP’s opendir is not handling multibyte characters properly, resulting in them being misread as individual single byte characters. Shift-JIS character table reveals that the letter ‘ソ’ has a value of 0x835C. So assuming PHP is misinterpreting the multibyte character as a single byte character, it would show up as 83 and 5C.
This is where the problem lies, because according to the ISO-8859-1 character set, 5C is the character code for the backward slash
\symbol. This becomes a problem due to the fact that Windows accepts both forward slash and backward slash as the director separator symbol. So
C:\Windowscan also be
Because of this, the word “ソフトバンク” can easily be misinterpreted as “ フトバンク” and in Windows, this refers to a folder called “フトバンク” which just doesn’t exist on my server.Read more »