Archive for the ‘PHP’ Category

I've been spending my project time learning how to manipulate images in PHP to let me create custom growth charts and the like, with a RESTful interface that would allow them to be used as the source of <img> elements. I like the way things turned out; they are available at bililite.com/webservices/. It includes height,weight, head circumference, peak expiratory flow (for managing asthma), blood pressure and bilirubin levels. While it took a fair amount of trial-and-error to get things to work, I don't think there's much that's innovative enough programming-wise to write a tutorial.

I want to get it to parse the Accept: header, so users can leave out the file extensions, but it looks like browsers don't implement that correctly, so I'll have to keep using extensions as well.

I still need to learn more about caching and effectively using eTags and all the headers that go with it. It always makes my brain hurt.

I decided that this blog is mine, rather than Young Israel's, so I wanted to move it to a domain that I personally own. Thus, it is no longer at youngisrael-stl.org/wordpress, but at bililite.com/blog. Moving the blog intact was non-trivial, so I'm recording how I did it, based on mydigitallife's instructions:

  1. Create the new folder, bililite.com/blog/
  2. Create a new mySQL database on bililite.com
  3. Copy all of youngisrael-stl.org/wordpress/ into bililite.com/blog/
  4. Edit the wp-config.php file to reflect the new database name/user/password
  5. Backup the youngisrael-stl.org database into an SQL file with phpMyAdmin or some other tool
  6. In a text editor, change all the "http://youngisrael-stl.org/wordpress" to "http://bililite.nfshost.com/blog" and "/wordpress" to "/blog". note that there are both absolute and relative URL's in there, and I was changing both the domain and the subdirectory, so I had to do two replacements. I couldn't just change "http://youngisrael-stl.org" because I didn't want to change links to the actual site.
  7. Run the edited SQL file on the bililite.com database
  8. In the youngisrael-stl.org/.htaccess , add the line "Redirect permanent /wordpress http://bililite.nfshost.com/blog" to let browsers know I've moved
  9. Actually announce the change on mailing lists of people who actually read the site

I've got a cheap website that doesn't let me use cron to schedule tasks (like database backups), so I had to do it myself. I found pseudo-cron, which looks cool but has some bugs and was more complicated than I wanted, so I wrote a simple PHP script to do what I wanted.

Continue reading ‘Scheduling tasks with PHP’ »

All I wanted to do was back up the Young Israel databases, some way more amenable to automation than phpMyAdmin. There are lots of PHP-based solutions on the web, but all seem based on mysqldump. I implemented one and found myself faced with an eyeful of אריאל מאיר יעקב בן דוד אברהם where the Hebrew names should be. Turns out this a known bug; mysqldump can't handle Unicode. There are reports of workarounds, but I spent 8 hours not getting anything to work.

So I had to write my own backup, going through each database on a server then each table in the database, writing the appropriate INSERT INTO commands (thank goodness the SHOW CREATE DATABASE and SHOW CREATE TABLE commands work correctly). It wasn't terribly miserable (not nearly as miserable it was trying to use someone else's tool that doesn't work), and now I get my  אריאל מאיר יעקב בן דוד אברהם just fine, and the backup works. I import the generated file into my local copy of mySQL and it regenerates the databases.

Continue reading ‘The Agony of Unicode (and backing up mySQL)’ »