September 7th, 2008 — php
If you look at my earlier posts, you’ll see I’ve become a bit of a Mac fan but when it comes to programming I’m sorry but you can’t beat Microsoft. I’ve been developing personal sites (such as RetailHealing.com) using php for about 3 years now but in my ‘real’ job I use ASP.NET in C#. You may disagree but I think that gives me an unbiased perspective on the two environments.
Whatever people say about Microsoft, they do create very excellent programming environments. I find Visual Studio easy to work with once you understand the configuration, build and publish model and I’ve yet to find a php development environment that makes programming more straightforward with features such as debugging, dynamic type ahead/autocomplete - I have heard that zend studio is the thing to use for php but I’ve personally not tried it yet.
Now to C# and ASP…
OK, so C# is very much a clone of Java and PHP but that suits me because I was trained in C and the move to Java, PHP and C# took very little time. But what I really, really like about C# and ASP is the way is handles web page processing and particularly forms with the code behind model. PHP is crying out for something like this. The closest tool I’ve found for this is Smarty [www.smarty.net] but what I would really like someone to do is implement the following ASP/C# features in PHP:
Postback handling
Panels
Labels
Validation
Authentication
Postback handing
ASP and C# manage all web interaction with the code behind model. The HTML page (.ASPX) controls the layout while the C# page sits behind the html and control the functional logic. Each time you click a button or interact in some way with the page, ASP initiates a ‘postback’ (actually a web form submit) and kicks off a page load and/or method in the C# code.
Of course, php gurus will say that all ASP is doing is using standard web form processing with some Javascript to do this - and of course it is. But I don’t have to write it, it’s all hidden from me as the developer and I can concentrate on the core logic. This also means that the code behaves consistently.
Panels
ASP:Panel - a great feature that I use all the time. Build a web page consisting of a number of panels - for example, one ‘welcome panel’, a standard user panel, an administrator’s panel and perhaps an error panel. Now, in your code you can make each panel visible or invisible at any point in the flow of the application.
Again, in php you can do this using divs with css and hiding sections as needed but ASP needs way less code to do the same and you don’t end up with hidden divs on the page which Google can frown upon.
Labels
OK, php is similar here. Instead of the php <%=variable %> in ASP you use <ASP:label id=name>but that same label can have serverside code behind it, click events, validation and much more.
Validation
Form validation in ASP is excellent. Need a field to contain something before the user can submit the form? Simple. Just add some validation code to the field along with some helpful error text to guide the user.
Authentication
Finally, Microsoft hasvery advanced in-built authentication and the web.config file which as far as I know, php has no equal of. Tell web.config that you want forms validation using a login page hooked into a user database table and that’s pretty much all you need to do to have a secure website. On each page, just check that the user is authenticated (User.Identity.IsAuthenticated) and that’s it.
I’m probably going to get a lot of flame posts from serious PHP programmers telling me about why I’m wrong and that there are ways to deliver the same functionality in PHP and I look forward to hearing about them. I think there is an audience of PHP developers who really need these features.
September 2nd, 2008 — websites
I guess you’ve all seen the announcements about the new Google Chrome browser. Here are some links to the comic book and features:
The key question is: “Do we need another browser?”
Google definitely seem to have taken the architecture of the browser a stage further to the point where it is starting to get operating system type features such as multiple processes that are isolated from each other, each with its own memory, data structures and an overall process manager.
The User Interface shots I’ve seen don’t seem to be that different and to me look like Opera, but I guess what else can you make a browser look like?
Embedding a new Javascript engine (V8) is a good idea and I can see Google Apps starting to appear more on the client side - this sounds very reminiscent of Sun Microsystems in the 90’s with the Java platform?
Apart from user confusion, I also worry about developers and browser compatibility - I already have Safari, Firefox, IE, Opera installed and cross-browser testing takes a fair time. Adding Google Chrome to the mix will certainly add development time.
What do you think? Is another browser needed and what do you think about Google Chrome?
July 24th, 2008 — os
You may have read my previous post (I’ve become a Mac OS X Leopard fan - way better than Windows) and I’m happy to report that my iMac at work is still running smoothly. Seconds to start up, doesn’t slow down even running multiple applications.
It’s been so good that I got TWO more iMacs for home! …maybe this is becoming a problem
As I do a fair amount of .NET ASP development as well as php, I will need to install Windows on the iMac at some point and I’ll probably use the Parallels application to allow me to run both OS X and Windows at the same time. In fact the Bootcamp provided by Apple to run Windows was a bit of a letdown as I discovered I had to choose my OS at startup and needed to reboot to switch. Not good.
Now I’ve been using the iMac for a while, here are some of my recommended applications.
1. Dreamweaver …way quicker than on a PC and in my opinion still the best web development tool
2. CSSEdit …one of the best looking and featured CSS editors there is
3. iMovie and iDVD …it took me no time to use these apps to import movies from the camcorder and put them on DVD.
4. Remote Desktop Connection… The quickest way to connect to remote Windows machines
5. Skype … great on the Mac. Fully integrated with the inbuilt camera and microphone
The not so good…
OK, so I’ll admit it, there are a few things I don’t like:
1. Lack of a decent messenger client with ICQ. I’ve tried ICQ, PSI and others but nothing seems to be quite right and why doesn’t iChat support more transport protocols?
2. The ’squeeze’ buttons at the side of the mighty mouse are far too sensitive making all my windows visible without me intending it
ummm… that’s it.
February 15th, 2008 — websites
You know how it is, you have your new website running, you followed all the right Search Engine Optimization (SEO) tips and structure your pages well with the right meta tags, content and layout. Then you consider your next step… building a solid foundation of inbound links.
As if by magic, a few days later and probably every other day from then on you receive that familiar email…
I think your site is really interesting and I wanted to link to it from my wonderful.com website?
I wanted to check with you first. I have over 100,000 monthly visitors and I would like to bring you a bit of increased traffic.
Is it also possible for you to link back to me from your site?
Be warned, it’s likely to be a link exchange scam for their SEO benefit…
In the good old days of the web, there was a real community spirit and people would happily provide links to each others sites. Nowadays with every site competing for those 10 positions on page 1 of Google things are unfortunately different and you may well be dealing with a link exchange scammer who will benefit from your link but tell the search engines to give you nothing back in return.
So, before you go ahead and agree to the link exchanger’s request, let me tell you about some of the things to look out for.
Go to the link exchanger’s site, find the page where they are suggesting they will add a link to your site and view the source code of that page.
1. Meta data telling search Robots to not index or follow
Look for the presence of a line within the <head> section of the code that looks like this:
<meta name="robots" content="noindex,nofollow" />
This tells search engines that this page should not be indexed and not to follow links on the page. So, if your page is listed on this page it will be ignored by the search engines.
2. The nofollow attribute
Take a look at the individual links on the page, if they include the nofollow attribute and look like this:
<a href="http://linktosomesite.com" rel="nofollow">Link to some site</a>
Then that link will be ignored by search engines.
3. Robots exclusion
Take a look at the site’s robots.txt file (www.theirdomainname.com/robots.txt) and look for a line that excludes the page containing external links. For example:
Disallow: /links.html
Again, if a line like this exists, the site manager is a link grabber and any of your links on their site won’t be given credit by Search Engines.
4. Indirect links to your site
If you’ve managed to avoid all the above pitfalls and you are ready to get your link added to the link exchanger’s site, hold on, we’re not done yet. Even if they are honest enough not to have written clever code to fool the search engines, you may find that links on their site aren’t all they appear to be.
For example, they may be using code behind what appears to be a genuine link to redirect to another page which then launches your website. This is all well and good for human visitors but a search engine will never run that code.
Say the link appears to go to www.mywebsite.com, take a look at the code and you may see something like this:
<a href="/linkdirectory.php?id=3245>www.mywebsite.com</a>
You’ll see that instead of giving search engines some nice clear keywords and a website to visit, they are directing the link to a piece of code that will then forward the visitor (but not necessarily a search engine to the site).
My thoughts on this
I think it’s a sad state of affairs when website links are traded like a valuable commodity. The web is about networking and community. The millions of pages competing for search popularity has diluted the value of the <link> tag to almost purely a search engine optimization tool.
Almost all the major blogging platforms have set all comment links to be “nofollow” because of this. Wikipedia has also made all external links “nofollow”.
HTML link categories
I can see a point where the HTML link specification will need to be expanded to support different categories of links: commercial, trusted, personal etc. with a way for both search engines and web users to see the difference when browsing pages.
The end of page rank?
The current “nofollow” method is reaching a point where web masters are becoming so protective of their site’s page rank that they are reluctant to give a genuine link away. Maybe that’s the solution - drop page rank and base a sites search rankings on other factors such as content quality, hits and perhaps even recommendations from real visitors?
Adam
February 10th, 2008 — os
I’m sorry Bill but I purchased an Apple iMac last week and I’m converted. But it’s ok, I’m still using a PC at home… for now.
I now see why there are heated debates between the two religions - Mac OS X and Windows. Being a PC user, I never really “got” the Mac thing and the last time I used a Mac in anger was 1991.
However, last year I started to become really frustrated with Windows. How after a fresh install, it would get slower each month as the registry grew. Also, how it would decide an urgent update was required and stop me working for 20 minutes while it installed. Or when everything would freeze as the anti-virus decided to do a weekly scan. Or perhaps it was the 15 minutes I’d have to wait for it to boot when I switched my PC on at work each morning.
So, last week I got a gorgeous iMac with a huge 24″ screen in brushed aluminium running OS X and became a Macophile.
Day 1 was all “ah’s” and “ooh’s” as I revelled in the beauty of OS X Leopard. I was amazed that everything just worked - networks, printers, even Windows file systems were detected by my iMac and worked faultlessly first time.
Day 2 I discovered the Dashboard and played with the Dock. Features like Spaces made Windows look so out of date - a simple squeeze of my mighty mouse’s side and all open windows were visible. No longer would I spend ages looking through layers of windows looking for that elusive application.
Then I plugged in an external drive and turned on the Time Machine. Wow. I certainly can’t say I’ve ever been excited by backing up files before but Time Machine is incredible. Every hour it incremently and silently backs up my files. If I ever need to recover something, I simply launch the Time machine interface and move back through time to locate it. Being OS X Leopard of course, it does this in real style with all backups moving back in time to a space vortex in the distance.
I love the little things like how I can create, preview and edit PDFs - something not possible in Windows without extra software. Same for image editing, all in-built within Leopard. In Leopard, you can preview files in the finder without opening the documents - even Microsoft Word documents can be previewed on the iMac without opening the file. How come you can’t do this on Windows?!
Startup and shutdown of OS X Leopard can be measured in seconds rather than minutes and performance so far has been excellent. We do some fairly intensive graphic processing in the office and a colleague was having problems rendering an image on his NEW high spec PC. It was taking him 24 minutes to process the file. We performed the same operation on the iMac in 3 minutes.
Of course it’s early days but I’m definitely hooked and I will write again in a few weeks to tell you all how I’m getting on.
January 23rd, 2008 — websites
If you search for the keyword SEO online, there are hundreds if not thousands of sites out there offering advice, consultancy and “top 10″ SEO improvements that you can make.
What I’m hoping this article will do is look at the problem from a practical angle based on what I’ve learnt from working with SEO experts who I rate highly and from real world experience running many websites. I’m not offering any commercial services on this site and will try and remain impartial to give you what I believe are the best solutions for getting your website higher in the rankings than others.
What is SEO?
First, I guess I’d better clarify what I mean by Search Engine Optimization or SEO. When I say SEO, I mean the process of improving the volume of traffic to your site from search engines and improving the chances of your website appearing higher in search engine results for specific keyword combinations that are relevant to your site’s content.
A few words of warning though. Nothing in the SEO world is guaranteed and anyone who says otherwise isn’t being completely honest with you. By applying the SEO tips in this article the chances are that your site will move up in the search engine rankings but by no means would I ever say you’ll get to page 1 of the search results.
Google, Yahoo and MSN never publish their algorithms and they are always being updated. If you try and trick the engines you’ll eventually be caught out and your site may drop like a stone or even worse you may be blacklisted. Attempting to trick the engines is often called “Black Hat SEO” and is definitely not recommended by me.
It takes time
Like all the best things in life, SEO takes time. Don’t expect to make changes to your site and see an overnight improvement. In my experience, many changes can take between 1 and 3 months to start making a difference. This is a double edged sword because if you make a change incorrectly or try something new that doesn’t work, you won’t notice for some time then once you do it’ll take ages for the fix to make a difference.
So, with that said, let’s get to the SEO tips:
Practical SEO tips
1. Understand your site
Before you embark on any SEO related improvements, the first step is to understand your site and your current traffic. I would recommend three proven methods:
1. Google webmaster tools
2. Google analytics
3. Xenu link checker
Google webmaster tools will tell you exactly about your site’s visibility in Google, where your site has errors, who is linking to you and how often the site is crawled. My favourite feature is top search queries which is able to tell you keywords people have used and where your site appeared in the results even if they did not go on to click your site.
Google Analytics has to be one of the best online toolsets available. By adding a few lines of code to each page on your site, Google Analytics allows you to track visitor numbers, landing pages, page views, time on site, geographic breakdown of visitors and even the city they came from.
Xenu is a downloadable tool that will quickly analyse your site and report all broken links. Invaluable.
You should spend a lot of time with these tools. I personally use Google Analytics daily. You should review traffic and then optimize your content and pages accordingly.
2. Content is king
Nothing is more important than content. A well structured site without content is like a ferrari without an engine - great looking but useless. You need to love writing articles, managing feedback, reviewing links and everything else associated with running a website with real visitors.
Remember that your site is for two audiences - real people and search engines. However your content should only be written for real people. Don’t create clusters of keywords or worry about keyword frequency and density. Simply write regularly with content and articles that are consistent with your site’s intent and that you think your readers will enjoy reading.
There’s no clear rule on frequency but I would recommend trying to post at least a couple of articles per week. It is important not to copy content from other sites and not to plagiarize. Search engines hate duplicate content and will penalize you accordingly. Copyright owners will chase you if you use their work without permission - a polite request is often all that is required if you want to use material from others on your site.
3. Other sites need to like you
If you write good quality content the visitors will come and other sites will link to you. If you are starting out, link directories are one way to quickly build inbound links but be careful as Google is beginning to penalize sites that do this.
I would recommend the SEO friendly directory site for a list of quality directories. After you’ve been running for a while you will find you need these directories less and less.
4. Remove page errors
404 errors, server errors, missing links are bad for your users and bad for search engines. Use tools such as Xenu and Google Webmaster to eliminate them.
You can read another article about how I was caught out by a strange 404 error.
5. Make life easy - use a content management system
If your site is hand coded using PHP, ASP, JSP or any other fine coding language and your content is coming from a database or even worse static you will spend hours updating, tuning and improving.
Some people love this but as you create more sites and more content it will begin to wear you down.
Using a Content Management System will make a huge difference - many now come with embedded features such as feeds, tags, pretty URLs and page designs that are very SEO friendly. I am personally a big fan of WordPress and I use it for both blogging as used in this site and also as a general purpose content management platform. WordPress has an extensive library of plugins, many of which are ideal for SEO purposes. I run WordPress with plugins for MetaTags, Tag Clouds, Feedburner and Google sitemaps which all help me with search engines.
6. Titles, titles, titles
Make sure every page on your site has a unique title and that the title accurately describes the content of the page first using relevant keywords. For example, on a website about travel and a page about Italian hotels, instead of the title “TravelSite”, put the page description first and the site title last like this “Hotels in Italy ~ By TravelSite. Everything about Travel”.
Not only will this give your pages unique titles but it will also give search engines an indication of relevant keywords for pages and make the title clear when the page is listed in search results.
7. Page tag structure
After the title, you should structure your page in a clear hierarchy. H1 tags are the most important but only use this tag for content titles on the page that are significant. One or two H1s per page is really enough. Including too many will confuse the search engine.
After the H1, use H2s for article/section titles, H3s for subheadings and so on.
The rule is to give your page a clear keyword and content hierarchy to help the search engine (and your visitors) navigate the page.
Finally, I would also recommend a one line footer that links back to your home page containing a sentence with your most important keywords. For the travel site, this could be “TravelSite - Accommodation, Flights, Guides and Discussion about top holiday and travel destinations worldwide”.
8. URL format
Many sites use a confusing URL structure such as http://site.com/page?parameter=22342. No keywords are included and it gives readers no indication what the page is about. I would recommend a keyword based URL format such as http://site.com/545/skiing-and-snowboarding-in-canada
You can immediately see that this URL is both search engine friendly and user friendly. If you use a platform such as WordPress, it can create this URL structure for you automatically.
9. Sitemaps
A sitemap is an XML file that guides a search engine to find all of your pages, it also tells the engine when pages are updated and which pages are more important than others. As your site becomes more important you will rely less on the sitemap but for new sites, it’s a vital tool. There are many tools out there that can create sitemaps for you automatically.
The second sitemap I would recommend is a human readable HTML sitemap that acts like a simple index to your site. Incuding this somewhere on your site not only provides a quick way for people to locate pages that may otherwise be difficult to find but also acts as a keyword guide for search engines.
10. Image optimization
Give every one of your images an ALT tag that describes the image to search engines.
Also, use Google Webmaster tools to allow image indexing of your site - it’s amazing how many extra visitors can come from a Google image search.
11. Link optimization
Give every one of your links a TITLE tag and also a description containing keywords. So, instead of:
<a href="http://www.somesite.com">www.somesite.com</a>
Do this…
<a href="http://www.somesite.com" title="A site about travel around the world">A site about travel around the world</a>
Again, this gives search engines those vital keywords.
12. Page rank
Page rank (PR) is a hotly debated topic within the web community. A site’s Google page rank is often seen as the badge of honour or embarrassment for a webmaster. Whole websites are devoted to discussing page rank and “High PR” directories abound that will only list websites with a PR4 or higher.
In simple terms, a page rank is a numerical value from 0 to 10 that indicates that web page’s measure of “importance” within the web community. The Google toolbar provides a toolbar that gives an indicative page rank for each page you visit or there are many websites out there that will show you PR values. The true Google page rank is of course hidden within Google’s search algorithm.
When you include a link to another site on your page, part of your page’s PR is given to that site. Conversely, when a site links to you, part of that site’s PR comes your way. This sharing of PR (or “link juice” as I like to call it) is how the PR system works and part of how search engines determine where pages are displayed in search results.
The idea of course is that the higher your PR, the higher your page will appear in results. Whilst this is of course partially true, there are many other factors that will also affect your results and PR is just one of them. I personally recommend that you don’t worry about PR too much. If you write your site well and keep posting good quality, relevant content then sites will link to you, visitors will come and your PR will increase. However, once you’ve got your PR, don’t just give it away…
13. Don’t give every link away
If you’ve read the PR topic above, you’ll see that I recommend that you don’t worry unduly about PR - it will come. The key thing is thought that once you’ve got your PR, don’t just give it away to every site that asks.
As your PR increases, you’ll be inundated with requests to share links with other sites. This will give away a small portion of your PR in return for a bit of theirs. If they have a lot of links and/or a low PR you’ll only get a tiny portion of page rank from them whilst you may be giving away more.
At the start of this article I talked about writing for two types of user - real people and search engines. People reading your site are the most important and I certainly recommend including as many links as possible to other sites that you think your readers will find useful but you don’t have to give your PR away on all these links to the search engine user.
If you want to include a link for your readers but instruct a search engine not to follow the link (and therefore not give your PR away), here’s what you do:
<a href="http://www.somesite.com" rel="nofollow">The link text</a>
Notice the “nofollow” within the tag. To a normal user, the link appears normal but to a search engine, this say stop there.
Using this technique, you can give your PR away to only those sites you choose to whilst still giving your readers the benefit of interesting links. This may not sound very community spirited towards fellow webmasters but it’s a competitive world out there and I can see the use and dominance of PR being reduced in the future because of this feature.
January 14th, 2008 — websites
Ah the joys of development. You spend hours crafting crafting code into a functional website, you run as many tests as possible to iron out those frustrating bugs, finally you “go live” and release your creation into the world.
That’s when it really starts to test your patience. New bugs, Gotchas, missing links, misbehaving dynamic content you name it, it will happen. Then when you think you’ve fixed all those, something else will come along to kick you.
Today’s rant from me is because of a site that I thought was running perfectly. Orders were coming in (albeit slowly), traffic was reasonable and life was good…. until I checked my trusty Google Webmaster tools and discovered over 750 page not found 404 errors in my site for pages that I thought were working perfectly well for the user.
So, here’s the situation. A URL that worked absolutely fine from any web browser was returning a 404 page not found error to search engines. Suddenly Google and Yahoo think that my site has disappeared into vapour and those pages that have taken months to creep up the search results drop like a stone.
The reason for this was that I’d tried to be clever by integrating Wordpress as a Content Management System (CMS) into an existing site.
I’m a BIG fan of Wordpress, not only as a blogging platform at which it excels but also as a generic CMS that I can use to create dynamic content for my sites. Out of the box it includes a fantastic admin system, hundred of plugins, great php based API, user management, commenting system and of course Google loves content and Google loves blogs which really helps with my SEO efforts. I’ve used Wordpress successfully now to add regularly updated content to a number of site - for example, I use the Amazon Web Services API to query the Amazon database and create website that sell specific products such as Jewellery (Jewelry for US readers!). By using Wordpress as a CMS I can dynamically bring in articles relevant to specific sections of the Jewellery site - for example, an article about the latest deals on Watches in the Watches department.
Back to my problem… what I done in my site is use an .htaccess file to allow pretty URLs to be used. For example: the URL /products/department/watches would actually go to the file /products.php?department/watches.
To integrate Wordpress into a site, you add the following code:
<?php define('WP_USE_THEMES', false); ?>
<?php require('./blog/wp-blog-header.php');?>
Wordpress doesn’t seem to like me using an .htaccess file that isn’t in sync with it’s own Permalink structure, so when one of my pretty Wordpress URLs was passed to wp-blog-header.php, it couldn’t work out where the page was and returned a 404 error … but only to search engines!
I haven’t figured out why a 404 was being returned for search engines but users could quite easily see the pages. That’s the a real mystery that I’m hoping readers of this site may have the answer to.
January 8th, 2008 — hosting
I don’t intend for this site to be full of promotional rubbish or adverts but I have to say a few positive words about my hosting provider Dreamhost.
Over the years I’ve used a number of different companies, usually at the lower end of the budget (which of course you’ll say is why I’ve had problems) and they have all had their faults - poor site performance, poor support, restrictive terms, price creep an so on.
So, in 2007 I decided to consolidate all of my sites onto one provider. I looked into private hosting but I couldn’t really justify the price and in many cases my databases and email would still be shared. So it was back to shared hosting.
After extensive searching I discovered that many people recommended Dreamhost and the benefits certainly seemed tempting:
For a start 500Gb of disk storage and 5 Terabytes of monthly bandwidth that increases by 40Gb a week. Then they add in unlimited domains hosted under one account, unlimited email addresses, unlimited mySQL databases and support for advanced features such as video streaming.
All from $5.95 per month and I’m not even getting close to their bandwidth limits at the moment.
Too good to be true you might say but using Dreamhost has allowed me to currently host 7 of my sites within one affordable account and the performance to date has been excellent.
Their support has also been exemplary. A recent example was when I contacted their support team on Dec 31 (New Years Eve) and they came back to me within 10 minutes with a solution to my problem.
Anyway, don’t just listen to me, take a look at them for yourself.
January 8th, 2008 — php, xml
In all the sites I’ve developed to date, it’s actually quite rare to find a php bug so although this issue took me a day to fix, I’m actually quite pleased to have found one.
The issue:
Basically, using the php simplexml_load_string() function appears to affect session handling and corrupts the data used in the $_SESSION data causing the error “node no longer exists” error when session_start() is called.
I was using the session system to keep a breadcrumb history for a store I’m developing (retailhealing.com) and had a handful of session varables, each representing a page in the breadcrumb history (crumb1, crumb2, crumb3, … etc).
The code was something like this:
session_start();
...
for ($i=1;$i < 5;$i++) {
$snode='crumb'.$i;
$sdesc='crumbd'.$i;
if (!isset($_SESSION[$snode])) {
$_SESSION[$snode]=0;
$_SESSION[$sdesc]='';
}
}
...
[later in the code, I was also using simple XML]
$parsed_xml = simplexml_load_string($xml);
After the first call to session_start(), when the page was refreshed, I kept getting a ‘node no longer exists’ php error and I couldn’t figure out what was going on.
The solution
A Google search revealed a case similar to mine but the unfortunate poster seems to have been initially flamed by the respondents who rejected it as a bug.
This case was discussing the use of the simplexml_load_string() which I was also using in my code. As a test, I commented out all calls to this function and reloaded my pages. Everything worked just fine.
This pointed the finger of blame directly at the simplexml_load_string() after I of course had spent hours looking at how I was using the $_SESSION[] calls in my code looking for an elusive typo!
So, what was I to do? I could of course just not use simplexml and use a more complex XML parser but I really wanted a quick solution.
The answer was in fact included at the bottom of the case returned in my initial Google search. You need to cast all non string values assigned to session variables to strings as follows:
$_SESSION[variable]=(String)value;
So, my code snippet above now looks something like this:
session_start();
...
for ($i=1;$i < 5;$i++) {
$snode='crumb'.$i;
$sdesc='crumbd'.$i;
if (!isset($_SESSION[$snode])) {
$_SESSION[$snode]=(String)0;
$_SESSION[$sdesc]='';
}
}
This is the first and only time I’ve had to use casting in PHP and I’ve no idea why I need to do it in this case… I’m sure there must be someone out there who can explain?