Entries in Web (41)

Sunday
Sep062009

Apache can't write to /var/www/images

In Beginning PHP6, Apache, MySQL Web Development (Timothy Boronczyk et al, Wiley, 2009), Chapter 7 (Manipulating and Creating Images with PHP), on page 178 we are told to create a subdirectory in the web documents directory (htdocs or its equivalent, such as /var/www on Ubuntu).  Then we are told create a couple of web pages that attempt to upload an image into that directory. But, when I tried this, the upload failed because Apache did not have write-permission in the images subdirectory.  The problem was that the subdirectory was owned by root but Apache was being run by user www-data.

I was able to fix this by changing the owner of the subdirectory to the user (and group) that the Apache process was run under:

sudo chown www-data:www-data /var/www/images

Now the web pages could successfully upload images to the subdirectory.

(I then had another problem in that the web pages couldn't display the uploaded images, but that was down to me being tidy and putting the web pages in a subdirectory of their own (/var/www/ch07-1).  I fixed this by changing "images" to "../images" in an <img> tag in one of the web pages.)

Thursday
Sep032009

A Bug in Beginning PHP6, Apache, MySQL Web Development

I have been working my way through Beginning PHP6, Apache, MySQL Web Development by Timothy Boronczyk et al (Wiley, 2009), carefully doing all the exercises and examples.  In Chapter 6 (Letting the user Edit the Database), on pages 157-159, there is a listing called movie.php which, among other things, displays 3 drop-down selection boxes.  When I ran the program, I noticed that each option in these selection boxes appeared twice. At first I thought I had made an error in typing in the code, but no, I had typed everything in correctly.  Here is the loop that constructs the <option> tags for the first selection box:

while ($row = mysql_fetch_assoc($result)) {
    foreach ($row as $value) {
        echo '<option value="' . $row['movietype_id'] . '">';
        echo $row['movietype_label'] . '</option>';
    }
}

The clue lies in the fact that the foreach loop declares the name $value but $value is not referred to anywhere in the loop body. The loop body accesses the elements of $row directly through their indexes. The foreach loop is not needed; all it does is cause the option to be duplicated. This is what the code should be:

while ($row = mysql_fetch_assoc($result)) {
    echo '<option value="' . $row['movietype_id'] . '">';
    echo $row['movietype_label'] . '</option>';
}

The same correction should be made to the two other selection boxes in movie.php. It also needs to be made to the version of movie.php on pages 167-170.

Friday
Aug142009

Microsoft silently installs a Firefox Add-on

I just noticed that I have a Firefox add-on installed that I have no recollection of ever installing.  This is the Microsoft .NET Framework Assistant and it appears to have been installed back in February 2009 as a part of .NET Framework version 3.5 Service Pack 1.

When I first saw this add-on, I was a little worried, and my first reaction was to attempt to disable or uninstall it.  However the "Disable" and "Uninstall" buttons were greyed-out.  Needless to say, this has been portrayed in a rather sinister light out on the web. For example, see here.  Also, note that someone has added the tags "backdoor" and "malware" to the page at MSDN that describes this add-on. However, Microsoft insider, Brad Adams says here that the greying-out was down to an oversight by the .Net Framework team:

We added this support at the machine level in order to enable the feature for all users on the machine.Seems reasonable right? Well, turns out that enabling this functionality at the machine level, rather than at the user level means that the "Uninstall" button is grayed out in the Firefox Add-ons menu because standard users are not permitted to uninstall machine-level components.

The good news is that the latest update to the .Net Framework, which was installed on my machine this morning, re-enables the "Disable" and "Uninstall" buttons on the .NET Framework Assistant add-on, so you can now disable or remove it if you wish.

However, it still remains rather worrying that Microsoft should think it OK to silently install stuff into a rival company's browser, when that stuff could adversely affect the operation of that rival company's browser.

Wednesday
Jul082009

That 1969 Feeling

With the recent flurry of television programs on the 40th anniversary of the Moon landing, it has been quite easy to imagine that we are back living in 1969.  However, I was a bit surpised when I saw the dates in the above advertisement for ScienceBlogs on the New York Times science page.  Presumably this is the result of a programming bug.  I am currently learning Javascript and web programming, and have been spending what seems like several hours per day for the past two weeks investigating similar bugs, so I am becoming rather sensitive to such quirks on web sites.

In what appears to be a reciprocal agreement, there is also an advert for New York Time science articles on the front page of ScienceBlogs, and recently this seemed to get stuck at only displaying a fixed set of articles from several months earlier.  Presumably this was also the result of a programming bug.

Saturday
Jan312009

Google warns that Google may harm Your Computer

Zoe just pointed out to me that Google is currently flagging all search results as potentially harmful to your computer, even Google itself!  It looks as if something must be wrong with their malware checking.

Page 1 ... 3 4 5 6 7 ... 9 Next 5 Entries ยป