Posts filed under 'PHP'
For the past couple of weeks, online stores in the United States have been out of stock of The Essential Guide to Dreamweaver CS3 with CSS, Ajax, and PHP. I’ve been in touch with my publisher to find out what the problem is. Apparently, the book has proved far more popular than expected. The book is being printed for the fifth time in less than a year, and supplies should soon be back to normal. It’s also available as an eBook by going to the book’s page on the friends of ED site and clicking the “buy as eBook” link.
June 2nd, 2008
Many people were underwhelmed—wrongly in my opinion—by the last two releases of Dreamweaver. Well, Adobe has been working for the past year on the next version (Dreamweaver CS4), and it’s taken the bold decision to release it as a public beta. Be prepared to be stunned. It’s got a new interface to give an overall feel of unity with the rest of Creative Suite, but the changes are much more than skin deep.
I have prepared a couple of video tutorials to give you a whirlwind tour of some of the main new features, which are now live on my website. In the meantime, get on over to Adobe Labs to grab your own version of the Dreamweaver CS4 public beta.
You need a serial number to use the beta beyond two days. To get a serial number, you need to have a valid serial number for Dreamweaver CS3 or any of the CS3 Creative Suites. There’s also a forum to discuss things you like and don’t like about the new version. Don’t forget that it is a beta, so not everything is working perfectly yet. Developer Toolbox users also need to be aware that the current version of ADDT is not compatible with the public beta.
If like me, you’re heavily into server-side technology, you might be disappointed that there are no significant changes to the server behaviors. But believe me, there are so many brilliant new features (the full list is on the Adobe Labs site), this is the most significant upgrade to Dreamweaver since the release of Dreamweaver MX six years ago.
Grab it, and enjoy!
May 27th, 2008
I’ve had my head down for the past few months pounding away at my next book, PHP Object-Oriented Solutions. I put the finishing touches to the final chapter a couple of days ago, and it’s now in the hands of the friends of ED technical review and editorial process. There’s a preview of what the book contains on the foED site, and I plan to get more details up on my own site in the not too distant future.
The book is due to be published in August. The date was chosen because that’s when all support for PHP 4 officially comes to an end. The painfully slow migration to PHP 5 by hosting companies has severely hindered the adoption of object-oriented programming (OOP) among PHP developers, but I hope this book will convince readers that OOP makes for cleaner scripts that are easier to maintain. PHP Object-Oriented Solutions is aimed at readers who feel at home with basic PHP, but want to take their skills to the next level. It’s a gentle, but fast-paced introduction to the delights and mysteries of OOP.
May 3rd, 2008
All this week, Adobe is running Adobe Developer Week, a series of seminars on web development. On Friday 28 March, it’s my turn to give a talk called “The Essential Guide to Dreamweaver CS3 with CSS, Ajax, and PHP”. If that sounds an incredibly ambitious subject for a one-hour talk, it is, but what the heck. Actually, Adobe simply decided to use the title of my book; but there’s no way I can cram the content of all 750 pages into my talk, so what I plan to do is give a little flavour of each aspect: CSS, Adobe’s version of Ajax (Spry), and PHP. I’ll be demonstrating live with Dreamweaver, showing tips and best practice techniques.
So, why not join me online at 1600 UTC (0900 PST) on Friday? To participate, you need to register on the Adobe website. Up to 2,500 can join the live presentation, and it will be available as a recording about a week later. One lucky person joining the live seminar will be chosen at random to receive a free copy of Dreamweaver CS3, Flash CS3, or Flex Builder 3. (Unfortunately, for legal reasons, the draw applies only to the US and Canada.)
March 26th, 2008
A week ago, I wrote about the blip in supplies of The Essential Guide to Dreamweaver CS3 with CSS, Ajax, and PHP. My publisher (friends of ED) got onto the case immediately, and told me that 388 copies of the book were on the way to Amazon.com. You might think that would be enough to keep Amazon going for a while. Indeed it did—about one day. Now, although I’d love to sell that number of books in a day—and every day—for a sustained period, books about Dreamweaver and PHP don’t fall into the same category as Harry Potter. The reason the mountain of books disappeared so quickly is because of back orders waiting to be fulfilled.
I’ve just checked Amazon again—and on Monday morning (London time, 28 January), the book was back in stock, but there was only one copy left. Wow, this book is hot! Grab it while you can. Nothing pleases me more than to see my book fly off the shelves, but it’s equally frustrating to see readers unable to get hold of a copy because demand was higher than anticipated. I see that Amazon is now quoting 4 February as the date supplies should be back to normal. Let’s hope it’s no later than that, and preferably sooner.
January 28th, 2008
For the past couple of weeks, the availability of The Essential Guide to Dreamweaver CS3 with CSS, Ajax, and PHP has been listed on Amazon.com as “usually ships within 1 to 3 weeks”. Very often, particularly with a recently published book, that means demand has been higher than expected, and there’s a temporary blip in supply. However, today the availability suddenly changed to “usually ships within 3 to 6 weeks”, so I decided to get in touch with my publisher to find out what’s going on.
Apparently, demand for the book has risen in recent weeks, so that’s good news for me. Thank you to everyone who has bought a copy. It has also been reprinted, and I’m told the new copies should already be in the distribution chain. Apologies if you have ordered a copy, and still haven’t got it. We’re trying to find out if we can speed up deliveries. [Update:] It looks as though things are moving. Amazon seems to have got hold of a few copies, and it’s quoting January 30 as the day when supplies should be back to normal. If you can’t wait, The Essential Guide to Dreamweaver CS3 is available for immediate download as an eBook. You can buy it through visiting the book’s page on the friends of ED website. By the way, this distribution problem does not affect Amazon in the UK, where the book is reported to be in stock.
January 22nd, 2008
One of the features I stressed in PHP Solutions was the need to write secure code. On page 378, I said it was essential to display error messages in a development environment so that you can debug your code. However, raw error messages look unprofessional in a live website. Well, guess who forgot to take his own advice? Yes, it was me—guilty as charged. Do as I say, not do as I do.
I found out as a result of a couple of messages posted under a pseudonym to my blog. Since I have been involved in an acrimonious discussion about security in the past couple of days, I suspect that someone involved in that discussion, either as a participant or an observer, wanted to embarrass me. The way in one of the messages was phrased appeared to be a direct reference to something I had written in the other discussion. Sure, I’ve ended up with (a little) egg on my face, but the error message didn’t reveal anything about the structure of the site; and I have now implemented the advice on page 378.
Am I embarrassed about the event? Yes, I suppose I am, but we all make mistakes from time to time. If I have made a mistake, I’m usually the first to admit it, particularly if the person pointing it out does so in a spirit of mutual help. I decided not to publish the messages—not to save my red face, but because the poster didn’t have the decency to use his (or her) own name, and because it was done in an offensive way. The poster accused me of wasting my time in a forum that I haven’t visited probably for about two years, although it’s a forum that provides a lot of free and usually very sound advice about website design.
Security on the web, as well as in everyday life, is important to all of us. Pointing out another person’s mistakes can be a valuable service. It’s not a question of scoring points, but of helping one another. Throughout the other discussion, I used my own name, as did most other participants. We had a genuine disagreement, but everyone was open about it. Sadly, the person who found a minor security error in one of my pages decided to be abusive and hide behind a false name. So, whoever you are, thank you for bringing it to my attention, but your actual posts have been sent to cyberoblivion.
January 22nd, 2008
PHP 4.4.8 was released today (3 January 2008)—three days after PHP 4 officially reached the end of its support life. For some strange reason, PHP releases are always made on a Thursday, so the release was delayed until today to avoid slipping it out on 27 December while everyone was still comatose during the Christmas and New Year holiday season. This version incorporates a handful of fixes for security issues and bugs, but adds no new features. Unless a major security issue emerges between now and the Beijing Olympics (8 August 2008), this will be the last ever version of PHP 4.
My reaction? About time, too. PHP 4 should have been abandoned a long time ago. The problem is that hosting companies moved to PHP 5 at a glacial pace. Even now, three and a half years after the release of PHP 5.0, only one in four PHP websites runs on PHP 5. In the early days, administrators blamed stability problems and memory leaks on shared hosting. Since I use a dedicated server, I have never come across such problems myself, but PHP 5.1 and 5.2 have added stability and performance improvements that should overcome any objections.
Perhaps a major contributory factor to the slow adoption of PHP 5 has been the memory of what happened when register_globals was turned off by default in 2002. Suddenly, scripts that had worked the day before ground to a halt. Turning off register_globals was done to plug a gaping security hole in PHP; but so many people relied on variables being created automatically from form fields and URL query strings that exasperated system administrators turned register_globals back on in spite of the security risk. This was, of course, the wrong solution. Instead of permitting insecure scripts, hosting companies should have shown their clients how to write secure scripts by using the $_POST and $_GET arrays.
There’s now a fear that switching to PHP 5 will suddenly break all scripts written to PHP 4 standards. The answer is that—in the vast majority of cases—it won’t. The only area of major incompatibility between PHP 4 and PHP 5 lies in the object-oriented model. Even so, there should be no problems continuing to run old OOP scripts as long as you don’t try to mix them with ones written using the new PHP syntax. I have a large website written using PHP 4 classes, which I moved onto my PHP 5 server back in August 2004. It ran perfectly with no changes, and is still running happily.
If you’ve no idea what an OOP script looks like, you probably have nothing to worry about anyway. Object-oriented code tends to be used only by advanced developers. Those most at risk are cut and paste merchants who use code in their web pages without knowing how it works. As long as you get code from a good source, you don’t need to understand it in minute detail, but you do need to know what it’s for, and how it fits in with the rest of the page. If you’re worried that you might have PHP OOP code in your pages without realizing it, look for the -> operator. A typical line of OOP code looks like this:
$result = $db->query($sql);
The key to successful migration to PHP 5 is well-written code. If you have been using best practices, such as writing scripts to work with register_globals off, you should have no worries upgrading to PHP 5. Other things to check:
- Use
$_SESSION instead of session_register().
- Use
$_POST, $_GET, and the other superglobals instead of the deprecated long versions, such as $HTTP_POST_VARS. Many PHP 5 servers don’t support the long versions; and even if they do, you should never mix them with the new superglobal arrays. When created alongside each other, they are treated separately, and changing the value of one has no effect on the other.
- Make sure that you pass arrays as arguments to functions that expect an array. PHP 4 won’t complain if you pass a string instead. PHP 5 isn’t so obliging.
Migrating to PHP 5 is not only nothing to worry about, it offers a lot of advantages, the most important of which is that PHP 5 remains under development. Security improvements are constantly being made. There are also lots of new features that make coding simpler and more pleasurable. For example, writing to an external file is simply a question of using file_put_contents(); no need to mess around with file handles unless you need to read the file at the same time. PHP 5.2 also introduces a very useful set of filters for sanitizing user input. And working with XML is a piece of cake with the aptly named SimpleXML.
If your hosting company hasn’t yet announced plans to migrate to PHP 5, start pressing for it to do so now. Also, get an assurance that regular updates will be made to the version on your server. It’s no good your hosting company moving to, say, PHP 5.1.6, because the PHP 5.1 series is already dead. As the PHP “museum” page warns, older releases are listed for archaeological purposes only, and they are no longer supported.
While checking on your hosting company’s offering, it’s also worth checking which version of MySQL is being offered. Few people seem to realize that all support for MySQL 3.23 ended more than a year ago. Active support for MySQL 4.0 and 4.1 also ended in 2006 (extended support continues until the end of 2008 for 4.0, and until the end of 2009 for 4.1). With MySQL 5.1 due out any time soon, you should be insisting on a minimum of MySQL 5.0. At a push, 4.1 will do.
This isn’t advocating the latest versions just for the sake of being up-to-date or trendy. Security on the web is extremely important, and it’s unrealistic to expect the developers of PHP and MySQL to keep patching up older versions. The PHP development team is working hard on PHP 6, but progress has been delayed by the constant distraction of maintaining two major versions at the same time as creating the next one. It also presents a problem for authors like myself. When I wrote PHP Solutions, I wanted to use PHP 5 code throughout, but I realized that the majority of readers would still be stuck with PHP 4. As a result, I had to write two versions of much of the code. With PHP 4 now officially no longer supported, there’s no reason to write books and tutorials that are hamstrung by the need to provide workarounds. So, if your hosting company doesn’t upgrade, you’ll find support for your system more and more difficult to come by.
January 3rd, 2008
The Dreamweaver forums have been ablaze with reports of simple PHP and ASP code causing Dreamweaver CS3 to crash. I have tested many of the sample code snippets, and can confirm that CS3 is crashing on Windows XP and Vista, but not on Mac OS X. It also affects the PHP code in my books.
The cause of the crashes appears to be the clock change following the end of summer time in Europe. Since the United States is still on daylight saving time until 4 November, American users have reported that they are crash-free—for the time being, at least. It’s not clear whether it’s an Adobe bug or one caused by the Windows operating system, but there’s little point getting into the blame game. What’s needed is a fix—and quickly.
The temporary solution appears to be to change your system clock back to any time before 2 am on 28 October. Alternatively, use Dreamweaver 8.0.2, which isn’t affected. Neither solution is ideal, but Adobe has been alerted to the problem, and hopefully a permanent solution can be found soon.
[Update]: The solution is to delete WinFileCache-********.dat, which was apparently corrupted by the clock change.
October 29th, 2007
I have just upgraded my Mac PowerBook G4 laptop to Mac OS X 10.5 (Leopard). The installation went fine, but there are a couple of issues you need to be aware of if you use your Mac to develop PHP, as they could affect your decision to upgrade—at least for the time being.
Leopard installs Apache 2.2.6 instead of the Apache 1.3 series that was used in all previous versions of Mac OS X. As a result, when you restart your computer for the first time, web sharing will be disabled. Turning it on is exactly the same as described in all my books. However, if you use the Mac OS X PHP package from Marc Liyanage, it won’t work.
Although Marc offers an Apache 2 version on his site, that won’t work on Leopard, either. According to a post from Marc on 26 October in this thread in his forum, he needs to figure out how to integrate it all, but is currently very busy at work. The same thread discusses using the version of PHP preinstalled in Leopard. Apple has inexplicably decided to install PHP 4, even though it comes to the end of its support life in just over two months’ time. [Updated 28 Oct 2007] As Dan Brown points out below, PHP 5 is, indeed, preinstalled in Leopard. The confusion is caused by Apache being in a new location. I suspect that the old versions of Apache and PHP were left on my machines because they were upgraded from OS X 10.4, and that a completely fresh install of Leopard would have only Apache 2.2.6 and PHP 5.2.4.
Following Dan’s instructions below will get PHP 5 up and running in Leopard. However, the default installation of PHP doesn’t read php.ini. You need to create that yourself. I’ll try to get some instructions up on my site in the next day or two.
I have no idea how long it will take Marc Liyanage to work his usual wonders with his PHP package, but if you want to use Mac OS X to develop PHP sites, either delay upgrading to Leopard follow Dan’s instructions below or use the all-in-one package from MAMP. I have never used MAMP, but it has a good reputation. Perhaps it’s time for me to give it a try.
[Added 28 Oct 2007] MAMP seems to work without problem on Leopard, and is definitely worth considering if the idea of working in Terminal sends cold shivers up your spine. After downloading it, simply copy the MAMP folder to Applications, and then double-click the MAMP icon inside the MAMP folder. I suggest that you select Preferences > Ports, and click “Set to default Apache and MySQL ports”. If you do this, it’s important not to switch on Web Sharing in System Preferences. You must also close down any existing MySQL server. It’s also important to realize that the Apache and MySQL versions installed by MAMP are completely independent. The site root and MySQL data store are in different locations. Any databases created in a previous installation of MySQL must be exported, and reimported into the MAMP version of MySQL. The need to move things around detracts from the attraction of MAMP if you already have several databases stored in an existing installation of MySQL.
October 27th, 2007
Previous Posts