How to refresh the projects file tree in NetBeans

This issue has been bugging me for a while and I just worked out how to solve it: if you’re using NetBeans and add some files to the project outside NetBeans (like copying and pasting in Finder/Explorer) then they don’t show up in the list of files in the projects tree view.

Calculating a page’s bounce rate with the Google Analytics API

I had an email a couple of days ago from someone asking me how to calculate the bounce rate for a page using my PHP Class for the Google Analytics API.

The formula supplied from Google from the “Common Calculations” section of the Analytics API documentation says the bounce rate for a particular page should be caculated like this:

ga:bounces/ga:uniquePageviews,ga:pagePath
 

To work this out using my PHP Class you would do something like the following example. I’ve multiplied the caculation up by 100 to give a percentage in this example.

$data = $api->data($id, 'ga:pagePath', 'ga:bounces,ga:uniquePageviews');
 foreach($data as $page_path => $row) {
 $bounce_rate = round(100 * $row['ga:bounces'] / $row['ga:uniquePageviews'], 2);
 echo "$page_path $bounce_rate%n";
 }
 

The round(…, 2) rounds the number to 2 decimal places (see my rounding numbers with PHP post for more details).

The above example would output the following from my own data as at the time of writing this post.

/jquery-get-set-form-values/ 87.17%
 /article/apache/restart-apache/ 94.31%
 /article/mysql/delete-all-data-mysql/ 91.23%
 /php-http-referer-variable/ 92.74%
 /check-uncheck-checkbox-jquery/ 86.73%
 /article/mysql/cross-table-update/ 88.99%
 /article/networking/open-firewall-msn-icq/ 94.37%
 /article/linux-unix-bsd/howto-check-md5-file/ 94.75%
 /upper-lower-case-strings-mysql/ 95.69%
 /install-yum-with-rpm-on-centos/ 87.36%
 

The defaults for the ->data() method will get data for the month to yesterday and for the first 10 records only. This can be modified to a different date range and/or number of records. For example, to get the same data for 1000 records for the same date range you could do this:

$data = $api->data($id, 'ga:pagePath', 'ga:bounces,ga:uniquePageviews', '', '', '', 1000);
 

I’ve realised in writing this I don’t actually have a post dedicated to the parameters for the data call so will write one and post it tomorrow.

Categories PHP

var_dump or print_r inside a Smarty template

While trying to debug why something wasn’t working, I needed to see what data had been assigned to a Smarty template but from within the template itself (I didn’t have time to try and work out where in the PHP code the stuff was assigned and debug from there). This post shows how to do a var_dump or print_r from within the Smarty template itself.

Categories PHP

PHP parse_url error for https requests from “Test Certificate Info”

The PHP websites I manage email me all notices, warnings and errors and I occasionally get warnings resulting from bots requesting bad URLs. This post looks at a PHP parse_url error caused by an incorrect piece of code that was published which has since been corrected, but there are clearly still scripts out there using the old code and making bad requests.

Categories PHP

Canon Easy Photoprint and CD LabelPrint Errors on Windows 7

I’ve recently reinstalled my main desktop computer from Windows 7 Beta 32 bit to Windows 7 Release Candidate 64 bit and had some issues using the bundled application software that comes with Canon’s photo printers (in my case the Pixma ip4300). This post looks at the errors and how I solved them.

When I switched on the printer Windows 7 automatically installed its own set of printer drivers. When I tried to use the CD-LabelPrint software I got the error message “A compatible printer for printing CD media was not found” as shown in the screenshot below:

a compatible print for printing CD media was not found

When I tried to use Easy-PhotoPrint I got the error message “No supported printer found. Connect a printer supported by this software” as shown in the screenshot below.

no supported printer found. connect a printer supported by this software

This is a rather confusing error because the printer was installed and was showing up in the list of installed printers.

It turned out the solution is to install the driver from the Canon website instead of using the default driver installed by Windows 7. From my research this also appears to affect Windows Vista, but it may be a 64 bit only problem and not 32 bit.

The drivers can be downloaded from here: http://software.canon-europe.com/