Parse error: syntax error, unexpected $end in /app/views/layouts/default.ctp – CakePHP

I just encountered an unexpected error while creating a portable development server on a USB stick using the latest version of XAMPP portable. This particular application runs on the CakePHP framework and was copied directly from another functioning Windows based machine.

After scratching my head a few moments I realized that the default configuration for XAMPP’s php.ini may be different.

The fix is easy. Go into your php.ini for your php installation and change the following from ‘OFF’ to ‘On’:

short_open_tag = on

Then simply go and restart your apache to apply the changes.

Tuning MySQL for performance with Ubuntu 11.04 and MySQLTuner

One of my current projects requires extremely heavy use of very large data sets housed in sever MySQL databases and spread across several servers. This data feeds various web apps, business processes, and fulfills many requests. It is data that needs to be highly available at all times and return queries in the shortest amount of time possible. There are several database tables with upwards of 15 million records and in some instances these need to be joined to other tables, used in calculations, etc.

I need results now, not 48 hours from now. Performance is essential but hard to come by with legacy servers made out of repurposed machines. In order to see where the bottlenecks are and try to make the best of the situation I decided to do some searching. We’re running Ubuntu 11.04 servers for this purpose and I needed something that would give me a run down of what’s causing performance issues on each server.

That’s when I found mysqltuner. This handy little guy is a Perl script that looks at your my.cnf and other MySQL installation data and makes recommendations about how to improve performance based on your past usage.

It’s easy to install in Ubuntu server 11.04:

sudo apt-get install mysqltuner

To run it:

sudo mysqltuner

Then simply enter your administratrive user and password and you’ll get a nice little printout like so:


This will give you a good set of recommendations about which settings to tweak. From here you can make tweaks, restart MySQL and run the script again to see where you stand.

Hope this will help someone in the same situation!

Error: Rejected send message–Ubuntu Server

I was doing some work on one of the development servers today and ran across the need to restart the MySQL server after making some configuration changes.

This is the command I ran:

user@machine:/etc/mysql$ service mysql restart

And this is the error I got:

restart: Rejected send message, 1 matched rules; type="method_call", sender=":1.7" (uid=1000 pid=20562 comm="restart mysql ") interface="com.ubuntu.Upstart0_6.Job" member="Restart" error name="(unset)" requested_reply=0 destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init"))

Wasn’t really sure what to try first but the first thing I tried was:

user@machine:/etc/mysql$ sudo service mysql restart

…and it worked like a charm. Just elevate your permissions with sudo if you run into this problem and it should quickly solve the issue.

PHP Fatal error: Call to undefined function curl_init()

I recently set up a development server in a VirtualBox VM running Ubuntu server 11.04. My plan was to move a development database and website to this VM and migrate away from a local XAMPP installation on a Windows box. The only problem is that Apache and PHP were not exactly the same between the two systems. This resulted in some of my scripts not working correctly. More specifically, I was getting the “PHP Fatal error:  Call to undefined function curl_init()” error. On my Ubuntu VM.

This likely meant that curl was not installed or enabled on Ubuntu, so here’s what I did:

  1. Run this command from a terminal:
    • sudo apt-get install curl libcurl3 libcurl3-dev php5-curl
  2. Make sure curl is enabled in your php.ini. This file is usually in “/etc/php5/apache2/php.ini”
    • In the section for dynamic extensions add (or uncomment):
  3. Restart Apache:
    • sudo /etc/init.d/apache2 restart

Missing orders in Virtue Mart admin and how to fix it

I just realized that none of the recent orders in one of the Virtue Mart installations I manage were showing up. It looks like the most recent one was….three months ago. But when I search for a more recent order I get the correct results. So, the orders are in the database but they weren’t being listed on the main order list. This will go over what I’ve found in this install of Virtue Mart 1.1.2. Other versions may not suffer from this phenomenon.


After a little digging I find that the order.order_list.php file in the /administrator/components/com_virtuemart/html folder has what I need to start my investigation. Starting at line 26 there is a bundle of SQL that joins the jos_vm_orders table to the jos_vm_order_user_info table. Well, since this is an administrator-only issue, I just echoed the $list variable at line 46, reloaded the order list in admin.

I then copied the query that was printed at the top of the page, replaced the #__{vm} with my installation’s table prefix of jos_vm and pasted the whole query in my MySQL tool of choice to query my database. Well, turns out the query isn’t returning an up to date result set. I know that the data for orders is being saved to jos_vm_orders because I can look at that table and everything is up to date. So next I move on to the table the query joins it with: jos_vm_order_user_info.

Aha! It looks like jos_vm_order_user_info wasn’t up to date at all. Weird.

According to this forum post it’s because there were custom fields added to the jos_vm_user_info database table and the jos_vm_order_user_info table no longer matched the columns. So the solution was to see what columns didn’t match up and alter the jos_vm_order_user_info table to have those missing columns. Turns out I added a single custom field and it didn’t get added to the order user info table…so after adding the column to the order user info table everything worked perfectly.

So, if you added custom fields to your user registration you should make sure your jos_vm_user_info table matches up those custom fields with the columns in jos_vm_order_user_info.

Ordering VirtueMart Child Items in Dropdowns

Ok, so a ton of people keep asking me about how to order child products in the dropdown list. I don’t develop with VirtueMart much anymore so the suggestions I give here are mere suggestions and have not been tested or put through any sort of trial. I’m just looking at the code and guessing at what to change.

This exploratory exercise uses VirtueMart 1.1.6 stable.

If it works for you let me know. If it kind of works for you but you fix something and it works better, let me know and I’ll update here.

  1. So let’s take a look at ps_product_attribute.php
  2. Somewhere in there is a bunch of functions that start with ‘list_attribute’. Let’s look at those.
  3. function list_attribute seems to be the main one that calls the other variations. It looks like by default it calls up the drop down menu for attributes. (line 221)
  4. Since that one is the default, let’s see if making modifications to any of its queries will give us the results we want. The function starts at line 241.
  5. At line 273ish you should see a SQL query: $q = “SELECT product_id,product_name FROM #__{vm}_product WHERE product_parent_id=$product_id AND product_parent_id<>0 AND product_publish=’Y'” ;
  6. This is the first query you’re going to play with. You can tack on any sort of ORDER BY directives that you wish:
    ex $q = “SELECT product_id,product_name FROM #__{vm}_product WHERE product_parent_id=$product_id AND product_parent_id<>0 AND product_publish=’Y’ ORDER BY product_name” ;
    I just ordered the SQL results by product name. You can put in whichever column or set of columns you wish to order by. It’s up to you.
  7. Now take this same principle and try it throughout the various ‘list_attribute’ functions and see if you can achieve the sorting results that you desire.

Playing with CSS3 transitions

So I’ve been wrapped up in a heap of projects and professional transitions over the past three months but I thought it time to get back to making regular updates of useful information.
This really boils down to the fact that CSS3 makes me all anxious and clammy like I’m about to go on a first date. Depending on which browser you’re using, you may have a wildly different date, though. This demo works in Chome, Safari, and partially in Firefox. I’ve used the information from Zurb to put this demo together along with a few of my own tweaks. If you want to see the demo and the CSS for it  – make the jump. Continue reading “Playing with CSS3 transitions”

HTML5 Isn’t ready for primetime, W3C says

According to the W3c, HTML5 hasn’t yet reached a level of maturity that would make it useful to the whole of the internet. Some browsers are capable of supporting some of the features while others don’t.

According to Infoworld:

HTML5, which updates the HTML specification to accommodate modern Web applications, has gained a lot of adherents in vendors like Microsoft, Google, and Apple. But the specification is plain not ready yet for deployment to websites, an official with the World Wide Web Consortium (W3C), which oversees HTML5, stressed this week.

I agree. It’s awesome and has great potential, but let’s not get ahead of ourselves. If we start making major time investments in developing sites in HTML5 now before it is a final standard, we could end up wasting time developing in the wrong direction. We’ll get there soon, but be patient. It’s probably more than acceptable to have fun and give the new potential tags and features a whirl….just be careful. You might shoot your eye out.

Google Instant Search Debuts

This is a welcome and logical development in the world of web search: get realtime google search results as you type. No need to hit that search button anymore. What has stopped a search engine from doing this previously? I’d wager nothing, but it sort of takes the search out of search engine and dilutes the magic of googling a bit. I’m satisfied with the interface and results it produces, although there needs to be more of a notification as to when the search results are updating.

Check out Google’s pep talk about it:

Internet Explorer 9 UI Video Leaks

I haven’t seen anything mind-blowing when it comes to IE user interfaces, and the next iteration of the popular and widely hated browser keeps the status quo as shown in the test video below.

It just looks smooshed and painful to use. It seems like there is a concerted effort to consolidate the navigation and menus to be similar to the new Firefox and Chrome builds…but it leaves a lot to be desired. It’s progress.

The only thing IE9 has going for it at this point is the 95% on the ACID3 test. But still, other browsers can pull a perfect score. IE9 seems to still be an underachiever, especially with all of the cash thrown at it. But I guess with the loads of Microsoft technologies that they have built reliance on IE there are some constraints to the possibilities.