Learning PHP

March 30th, 2005 : code, php, programming

Now that I have my own domain and access to a server, I’ve been poking around with some cool open source apps. One of the first applications I installed was Wikka (formerly known as Wakka). Wikka is an Wiki written in PHP with some great features:

  • PHP and MYSQL make it lightweight and fast. (Okay so that’s propaganda from the website but it really is great.)
  • Page level security so you can determine which pages can be viewed and edited by others.
  • Like other Wikis it uses the CamelCase syntax for links to other pages but it also has some neat tricks for creating elements like lists, horizontal bars, etc.
  • Its functionality can be extended using plugins called actions. People have written actions to display rss feeds and calendars among others.

This last feature really got my creative juices flowing. As I examined the actions that others had written and p0ked around the actions folder in the Wikka installation, I saw that people were doing some pretty powerful things using pretty simple code. One project in particular to make Wikka into a Personal Information Manager really excited me as I wanted to use the Wiki as a my online dossier for ideas, programming projects, etc. Seeing different implementations of to-do-lists, calendars and schedules made me want to build my own.

My first step was to start learning PHP and MYSQL. Since I do a lot of work with SQL in my day job on Wall Street, I knew I would have no trouble writing the queries I would need for my event calendar. Being a semi-pro VB developer I thought PHP as a sister programming language would be pretty straightforward as well. I picked up J.W Gilmore’s Beginning PHP5 and MYSQL: From Novice to Professional. The book is great for beginners, easy to read especially if you are familiar with basic programming concepts but not so basic that you feel the author is treating you like a novice. After the first sixty pages and a few examples, I felt confident enough to poke around myself and I printed out some of the Wikka action code to see if I could pull it apart.

With the help of the book and some specific searches of the PHP.net website, I was able to write a simple date action which would allow me to enter “{{date}}” on a Wikka page and it would print out a formatted version of the current date. Emboldened by the simple success, I jumped way ahead of my skill set to the end of Gilmore’s book and peeked at the code for connecting mysql to PHP. Here I was bested by the most humble of creatures: the semicolon.

I began my quest to connect a simple Contacts table in MYSQL to a small routine which would print out the results of a dynamic query into Wikka via a “{{contacts}}” action. I found some simple code on the About.com website and modified it with the login details from my own server. However, everytime I would load the sample.php file I would get a blank page. Coming from the VB background, I’m used to having Excel or Access shout at me via a dialog box with a cryptic error message which I would have to decipher using the posts of others on VB programming bulleting boards. By contrast this silent refusal to execute my commands was at first puzzling but soon became frustrating. I thought at first my php code didn’t like the MYSQL user name and password that I had set up for my test database. So I changed the user password several times. Then, I commented out the whole program and just concentrated on getting the connection to the database to work and print out “Database connected.” Once I got that working, I slowly started uncommenting my program line by line until the point where I would get the blank screen again. By the end of about two hours I had unraveled about half of the code and gotten it to work. My wife called me away for dinner sensing that I need some fuel. Nurished, I return to the joust. However as I was reviewing one line of code, I noticed that I was missing a semicolon at the end of the line. After adding it in and checking the remaining commented code for missing semicolons, I took a huge step and uncommented all of the code. With baited breath, I clicked the refresh button on my browser and to my joy, the formatted output of my query appeared in its proper place on my wiki.

My advice to young programmers who may find this post among the annals of history: remember your semi-colons.


Back in New York

March 27th, 2005 : economic development, featured

Back in the city after a visiting my parents in D.C. On the train ride back I read a recent Financial Times survey on India. Takeaway points:

  • Indian tourism is likely to boom over the next few years to some 10m passengers a year by 2010.
  • Displaying wealth is still highly frowned upon so luxury goods makers are having a tougher time in India than rival China.
  • By 2025, India will sent 800,000 students a year overseas out of some 11m current university students. Foreign degree still has cache even vis-a-vis Indian Institutes.

My general impression, India is getting hot but not explosive like China. It seems like expat Indians and Indians trained abroad are driving growth with Western companies only target very specific sectors of the economy (i.e. IT and some clinical drug testing). However, a small article in the survey on Indiagames, a cellphone game maker that has tied up with a Chinese cellphone content provider, Tom Online, illustrated that some Indian companies are moving beyond the “India Story” (i.e. low-cost outsourcing) and concentrating on being a world class players.


Beginning again …

March 27th, 2005 : featured

It seems like every few months I start and then stop blogging from a different location. After reading so much about blogging and its effect on the presidential election in the U.S., I jumped on the bandwagon in late November 2004 by starting a blog at blogger. It was fun for a while but I found that rather than the substance of my posts and I was more concerned with the style. I wanted a place where I could my “decorate” web home a bit by putting in new carpeting and changing some of the wallpaper. After a few days of searching on Google and reading the blogs of people I respect, I found WordPress, an open-source CMS which was easy to use and powerful enough to do some interesting things stylistically and programmatically.

My next task was to settle on a site that would allow me to host a WordPress blog for free. I found a new site called Blogsome which was offering a pre-packaged version of WordPress complete with some really impressive WP themes from Alex King. I signed on immediately and setup The Wandering Mind. I posted a bit here and there but time and other interests intervened so I didn’t make much use of it.

Then a few days back I decided to embark on the adventure of registering my own domain name and leasing space on a webserver. Once I got my site up and running, I knew that my homepage would be my blog and given that had access to a powerful server with lots of space and free reign to install anything I wanted, I made my way to the Word Press website and installed version 1.5. Following the excellent instructions, I installed the software in almost 5 minutes as advertised and had a blog template waiting to be filled with my thoughts and ideas.

However, my alter ego, the tortured artist, took over and determined that the Themes that WordPress provides in its default installation were not good enough and that I would to create my own Theme or at least modify one another one with my mark. Browsing del.icio.us for my links on CSS, I remembered Alex King’s site. When I reached the homepage, I was happily surprised to see that he had setup a new competition for WP 1.5 Themes. I browsed through some of the entries and tried a few. Two stood out above the others: Jakarta 1.5 and Gespaa. I used both for a couple of days and did some extensive modifications to Gespaa’s 2-column version but in the end the CSS in Gespaa was to complicated for me and I didn’t like the layout of the blog post text. So I returned to the competition website and found a Theme from the design duo of Patricia Muller and Sadish Balasubramanian at WPThemes.info. I fell in love with their the entry called Connections. I had been fooling around with a header image with my site address and a pithy comment ala New York Times’ “All The News That’s Fit to Print”. I grafted my image on to the Connection header image and created the site you see before you. I’m happy so far and think this that my current incarnation should keep me satisfied enough for the time being that I’ll concentrate on writing instead of tinkering with the design. But only time will tell.