Monday, September 28, 2009

Null Links Best Practice

There have been instance were you want something to look like a link, but do something else when someone clicks is.

There are some various solutions out there, but here's the one I recommend.

Format your link like this
<a href="requirements.asp" onClick="javascript:YourJavascriptStuff;return false;">
Here's how this works: Make a page called requirements.asp, and on that page you list the minimum user requirements required for users to use your site. Obviously JavaScript is one of them.

When a user clicks the link, if they don't have a Javascript enabled browser, or have Javascript turned off, it will send them to the requirements page.

If they do have Javascript enabled, the 'return false' interrupts the HTTP call make by the href and executes the Javascript instead.

So it looks like a link, and will act like a link if there's no Javascript. If there is, the Javascript call will execute.

Friday, September 18, 2009

Add Widget to Header | Add Widget to Post in Blogger

I was working in blogger and wanted to add AdSense to it in specific places. By default, I can add a html/javascript widget to the side bar, but there was no way to add a widget to the header or to the post. Wassupwidat?

I tried editing the HTML directly, but the AdSense ads wouldn't show. I didn't want to use the built in AdSense monetize featured because that doesn't allow for channel tracking. So I poked around a bit and found they way to do it.

Add widget capability to the header

Go to the edit html and look for
<b:section class='header' id='header'>
There might be some other stuff in there, but regardless you want to edit it to read:
<b:section class='header' id='header' maxwidgets='3' showaddelement='yes' preferred='yes'>
After you do that, when you go to the layout screen you'll have an Add Widget section. Now you can put in a html/javascript widget and put your adsense in there (or anything else).

Same thing for the post section. Look for something like:
<b:section class='main' id='main' showaddelement='no'>
And replace it with:
<b:section class='main' id='main' maxwidgets='3' showaddelement='yes' preferred='yes'>
Use the maxwidgets setting to control how many widgets you want to add.

Thursday, August 13, 2009

Send Email using ASP from a Web Form in GoDaddy

I'm not really fond of GoDaddy, just like I'm not fond of WalMart, but I still shop there. When it comes to cheap hosting, especially in a combined ASP/PHP/.Net environment, they're pretty much it. For less than $10 a month I can get 25 MySQL databases, 5 SOL databases, and unlimited top level domains. Can't be beat, or at least I couldn't find a place to beat it after wasting about hours of my life looking around before picking GoDaddy as my solution.

So I've been moving some of my sites over. Why pay $5 a month (which is still cheap) when I can get hosting for pennies? I mean, $5 isn't much, but when you're hosting 11 sites, it adds up.

Many of the sites I host use contact forms or confirmation forms, or some other form that needs to send out an email. Simple enough, but I spent a good three hours this morning figuring out how to do it on GoDaddy, and not for the reason you think.....

Before I get to that, here's the code:

sendUrl="http://schemas.microsoft.com/cdo/configuration/sendusing"
smtpUrl="http://schemas.microsoft.com/cdo/configuration/smtpserver"

' Set the mail server configuration
Set objConfig = CreateObject("CDO.Configuration")
objConfig.Fields.Item(sendUrl) = 2 ' cdoSendUsingPort
objConfig.Fields.Item(smtpUrl) = "relay-hosting.secureserver.net"
objConfig.Fields.Update

' Create and send the mail
Set objMail=CreateObject("CDO.Message")

' Use the config object created above
Set objMail.Configuration = objConfig
objMail.From = "sender@coolexample.com"
objMail.To = "recipient@coolexample.com"
objMail.Subject = "subject"
objMail.TextBody = "body"
objMail.Send

Set objSendMail = Nothing
Set objConfig = Nothing

Replace the hardcoded values for subject, from, to etc. with your own values. Bear in mind GoDaddy will only send 250 messages a day, so if you need to do more, you'll have to come up with some other solution.

Now here's the kicker. Two kickers, really:

The first is GoDaddy doesn't allow detailed error messages for classic ASP. All you get is a 500 Internal Server Error. I wasted a good bit of the three hours trying to figure out how to turn on errors but came up with nada. So good luck troubleshooting your ASP code....

And this is related to the above: I couldn't get the damn thing to work (and I couldn't see the error). So I ended up stepping through it line by line and guess what the problem was?

GoDaddy doesn't allow you to use a GMail address as a from address.

That's right my friends, Read it again.

So say you have a site with some sort of Send to a Friend thing where you ask for the sender's email, so the message says something like YourFriend@HisEmail.com has sent you a link and the from address is actually the person's email.

Well, if your address happens to be a GMail (and maybe other free mail apps, I didn't check) you get an error. An error that you can't troubleshoot.

Once I figured that out, the code worked fine, although I had to update some of my forms to change the sent from value so it didn't use the submittor's email address anymore.

Monday, August 03, 2009

RetroWebDev's No Joke Guide to Making Money on the Internet - Part 1: Introduction

OK, this is it. I know, I know, there are a ton of guides out there, most of them wanting money and most of them promising financial independence and near-instant wealth. You too can earn $3,768.18 a day!

Well maybe you can, but if that's the type of program you're looking for, read no further, because that's not the type of program I'm going to talk about.

I'm talking about a real, working-as-I-type-this program that has, for the last year, earned me between $1,000 - $2,000 a month. At my peak in December 2005, I had over $10,000 in revenue and just over $9,000 in gross profit.

But that's another story, for another time, and in another time, before the search engines had their huge affiliate crackdown in early 2006 and I went from $300 a day to $30. Ouch! Good thing I hadn't quit my day job....

That's probably worth making a rule: Don't quit your day job.

The type of pay-per-lead and pay-per-sale marketing I'm talking about can be a finicky beast, with companies and offers and products coming in and out of the marketplace and marketing terms being changed all the time. Nothing hurts quite so bad as having a well performing offer pulled out from under you or the terms changed to prohibit your most profitable marketing channel, but it happens all the time, for any reason (or for no reason at all).

Example: In 2007 I was doing $5,000 a month of a very popular diet program, only to have the company change their affiliate terms to prohibit pay-per-click marketing, because--Iwas told--they felt I was stealing sales they would have been getting! Bye-bye $5k....

This isn't to say if you ever do reach $3,768.18 that you couldn't quit. If you did, and it was coming in spread acorss a large number of offers and sites, and you had been saving $3,468.18 a day (or more) for the last 6 months, you still need to work. In that case, you probably don't.

If you're still reading, I'll assume you aren't making anything, or at least not that much, and you want to know the secret. By the end of all this, I think you'll see this isn't much of a secret at all. It's a proven method (at least proven for me in that it works and I get checks), based on some pretty solid and repeatable actions.

In other words, anyone can do it. But there are some things you need to have in place before you can get started.

Stay Tuned for Part 2: What you Need to get Started

Friday, June 26, 2009

Turn Off Comment Section in WordPress Pages

I'm setting up a WordPress install with the primary intent of using it mainly as a content management system (CMS). I'm tinkering because a family member has started up a business and is looking for a web site. I want to give them something robust enough to meet their needs, yet simply enough that they don't have to call me every time they want to update or add something.

WordPress is cake to install, so I had an instance running in less than 10 minutes. I edited the included About page that comes with the default install, turned off Allow Comments and Allow Pings, then viewed the page. At the bottom of the page it was still tacking on the comments section:


Ug. I poked around and couldn't figure out how to turn it off, so I resorted to a handy-dandy Internet search and found the solution.

In your theme, you will have a page named single.php, or index.php. Use the editor to view the source code for the page. In the code, the comments template is called with:
<?php comments_template(); // Get wp-comments.php template ?>

Comment that code out:

<!--<?php comments_template(); // Get wp-comments.php template ?>-->

and add this:

<?
php if(is_page(array(27,32,56))){
//do nothing
}
else{
comments_template();
}
?>

Where the comma separated numbers correspond to the page_id.

The comment section will still show up on blog posts, but not on any of the pages you identify in the above code.

Tuesday, June 23, 2009

Taking the eCommerce Plunge

Phase 1: Affiliate Links
For almost 10 years now, I've been trying to earn a living online, enough so that I could work for myself and own my time. I've been very successful earning extra money, but I never made enough, and with enough consistency (the most important thing), to quit my 'real' job.

The most I ever made was almost $10,000 net in one month (December 2005). Up to that point, my revenue had been growing every month for the better part of a year. I was giddy.

In March 2005, just three months later, after a big affiliate link 'crack down' by the search engine, I made just under $400. I was no longer giddy. Good thing I hadn't quit my job!

Phase 2: Pay-per-sale and Lead Gen
I started tinkered with other affiliate marketing, pay-per-sale, and lead gen programs, this time looking for offers I could market through PPC, and thus have control over my fate: Pay the mony, show up in the results, thus elminating the organic component. I had success there as well, but once again learned that in such a system, my fate was not in my own hands. Driving the traffic was, but the offer itself.....

I would research the offers, register a domain, build a mini site, do keyword research, and drive traffic through PPC on Google, Yahoo and MSN. Some offers were successful, but most weren't. The ones that were I ran with, for the ones that weren't I simply stopped spening money on marketing.

The successful ones almost always ended up being retail offers for strongly branded products (think late night TV commercials). Time and again I would build the site and get the ads out only to be contacted after a month or two and be told that the terms had changed and I was no longer allowed to bid on trademark terms (usually the product name). Down came the ads, and away went the traffic.

As an example, I used to run an offer for Nutrisystem. My revenue was around $8,000 a month on $3,000 in spend for a profit of around $5k. I did this for three months and was then told to pull my ads. Bye-bye to $5K.

This scenario played out repeatedly and I finally gave up. Term changes (no more PPC!) or the offers being pulled unexpectedly, leaving me with a worthless site, finally wore me down. I pretty much stopped trying.

Most of my sites still sit out there since. I was hosting them myself on my own server and they don't cost anything. They'll stay until the domain names expire. Recently, some of the sites started picking up some significant organic traffic, mainly from Yahoo and Bing. I've since reworked these, found some good fitting offers, and currently make between $1,000 to $1,500 a month. Not much, but I'll take it. It gave me enough moeny to try....

Phase 3: Drop shipping
All this frustration ultimately led me to deciding I needed to have my own ecommerce site. No more depending on selling other people stuff. I'd sell it myself! I wanted to be as efficient and cost-effective as possible, so drop ship looked like the perfect solution.

After a bunch of boring research, I choose a niche, found a supplier, and went with a hosted cart solution. The niche I chose only had two drop shippers in it. I spoke to them both and did my due diligence. One was hopelessly disorganized and the other seemed to have their ducks in a row, so I went with them.

Alas, appearances can be deceiving. After getting the site configured and the inventory loaded, I went out slow, slow, slow with the marketing to test the waters. The orders started coming in. Not much, maybe an average of 1 a day. But it was a enough to rapidly figure out that the supplier took anywhere from 2-6 weeks to fulfill an order.

Tip: when people order something, 2 weeks is about the longest they'll wait before they start asking you where it is.

Added to this was the manul process of passing the order to the supplier. No automated solution there; I had to send email(s) for every order, send email(s) to ask if they got the orders, then send follow-up email(s) for them to notify me when the order shipped, then send the tracking number to the customer. Not smooth, not easy, not efficient.

Turns out their primary business is manufacturing for retail stores, so drop ship items got tacked when ever they had to fulfill a wholesale bulk order, hence the wait. Order a blue widget? Have to wait until a retail store ordered 50, then they would make 51 and send yours out.

So after 4 months of operation, I shut it down. I ended up breaking even for the effort, but it was a lot of effort and a lot of emails.

Phase 4: Do It All Yourself
Still searching for some way to escape my corporate overlords, I once again forged into ecommerce.

My dealing with the supplier mentioned above led me to believe that although they hadn't worked as a drop shipper, they would as a wholesaler. I already had a decent relationship with them. It was OK to wait 4-6 weeks to get your stuff when you had stock on hand to do your own fulfillment, all you had to do was order ahead to keep your inventory level up.

The drawback here was the cash outlay for inventory. The benefit was you were in charge of getting the item to the customer and you got another 20% off pricing for wholeslae orders over a certain amount. That gave me a larger margin to work with for profit.

So I re-engaged with them and am currently getting things lined up for yet another effort to break free of my corporate bonds....

Wish me luck!

Thursday, May 21, 2009

Operation must use an updateable query

Microsoft JET Database Engine error '80004005'

Operation must use an updateable query.
I think every web developer has seen this error at one time or another, and probably more than once. When I see it now, I actually smile, because it's an easy one to fix. It happens when you try to add or edit a record in an Access database through your web site.

This isn't a database error per se, it's actually a permissions error. Without going into too much detail, it's cause when the Internet Guest Account on your IIS server doesn't have permissions to write to a folder.

The Internet Guest Account is the accout IIS uses by default for web site visitors. When you add or edit a record in Access, requires that the account editing or creating the record have write permissions to the folder the Access database it in.

If you have access to your server, open file exploere and navigate to the folder containing your Access databse. Right click, select Properties, then click on the Security tab. In the Groups or user name box, scroll until you see Internet Guest Account. Select it, then look in the Permission box underneath and make sure Write is checked.

If you don't have access to your server, you'll have to contact support at your hosting company and ask them to do it. Any hosting company wirth its salt with know exactely what you mean when you say "I need you to set write permissions for Internet Guest Account on the folder that has my Access database in it."

Thursday, May 07, 2009

Installing Visual Web Developer 2008

I haven't been doing much as far as advancing along the .Net development path. Procrastinating I guess. My cellmate at work suggested I go ahead and install the most recent version (2008) rather than the 2005 I already had, so I could use the 3.5 framework, since he said it had some "cool stuff". I figured why not? It's not as though I'd really started doing anything anyway.

So I downloaded the whole deal from the ASP.Net site and launched it. Three days of intermittent tinkering later, I finally had it installed. And Microsoft wonders why it has pretty much lost the hobbyist programmer....

The problem occurred right out of the gate. The install program hung on trying to set up the 3.5 framework, which was the second step of the install process. I tried all the standard solutions: uninstalling all the existing frameworks, reinstalling, even downloading the 3.5 framework separately and trying to get it set up that way. I thought maybe it just needed a long time to finish, so I let it sit overnight. Nope. It wouldn't install and, as a result, VWD 2008 wouldn't either.

As a last ditch effort, I tried Windows Update. I should have tried that first because it worked. The next time I ran the VWD 2008 install program, it went right over the 3.5 framework install with a green check mark and proceeded on.

I went through some similar contortions trying to get SQL Server 2008 Express and it's associated Management Studio installed, but I overcame that as well.

So now I've got Visual Web Developer 2008 on my machine. All that's left is learning to use it!

Thursday, March 26, 2009

Showing the Date and Time in .Net

I like the concept of master pages, they seem sort of like includes on steroids. In Classic ASP, I would build my template and use includes for those items that would be global to the site: header, footer, navigation, etc. master pages in .Net let you do the same sort of thing.

So I get my master page created and I want to put the copyright notice on the footer. But how to dynamically insert the year?
d, day of month: System.DateTime.Now.ToString(" d") // can't use just "d"
dd, zero-padded day of month: System.DateTime.Now.ToString("dd")
ddd, abbreviated day of week: System.DateTime.Now.ToString("ddd")
dddd, full day of week: System.DateTime.Now.ToString("dddd")
h, hour: System.DateTime.Now.ToString(" h") // can't use just "h"
hh, hour, zero padded: System.DateTime.Now.ToString("hh")
H, hour, 24-hr: System.DateTime.Now.ToString(" H") // can't use just "H"
H, hour, 24-hr, zero padded: System.DateTime.Now.ToString("HH")
m, minute: System.DateTime.Now.ToString(" m") // can't use just "m"
M, month: System.DateTime.Now.ToString(" M") // can't use just "M"
MM, month, zero padded: System.DateTime.Now.ToString("MM")
MMM, month abbreviated: System.DateTime.Now.ToString("MMM")
MMMM, month full name: System.DateTime.Now.ToString("MMMM")
y, year (omits century): System.DateTime.Now.ToString(" y") // can't use just "y"
yy, 2-digit year, zero padded: System.DateTime.Now.ToString("yy")
yyyy, 4-digit year, zero padded: System.DateTime.Now.ToString("yyyy")
So to actually use this in a page, you'd do:
Copyright <%= System.DateTime.Now.ToString("yyyy") %> 
This will write the full four-digit year.

Here's a full list of all the Date and Time formats.

Visual Web Developer 2005 and ASPNETDB.DBF

I've decided to initiate my .Net journey with the free Visual Web Developer 2005 Express Edition, mainly because the couple of books I have are for Visual Studio 2005 and the .Net 2.0 framework. I choose SQL Server 2005 Express as well for the database backend.

I'm not sure how easy it is to get VWD-2005-ED anymore. Microsoft released VWD-2008 about 6 monmths agao and it's all that's available from the official .Net website. I had a CD with it that had come with the Dummies book I bought a few years back. I bet you could find it on PirateBay or some other torrent sharing site though. It's free, so that's not stealing AFAIC.

It's taken me some time to figure out the nuances of getting a new web site project up and running. The main issue I was having was with VWD-2005-ED creating the membership database the way is was supposed to. Sometimes the membership database got created and sometimes it didn't.

After much trial and error, I hit on a sequence of actions that seems to work. I assume you have VWD-2005-ED and SQL Server 2005 Express installed, and have started the VWD program. Do:

File-->New WebSite-->ASP.Net Web Site - I'm working in C# and using the File System as the location

Once the program has created the site:

Build-->Build Website

Once the site has been built, hit control (Ctrl) F5 to launch the site preview in Internet Explorer. Close the browser after it finishes launching and then, back in VWD:

Website-->ASP.Net Configuration

This brings up the browser again with the configuration stuff loaded. It might take a minute or two. Once it's done, the ASPNETDB.DBF should have been created.

RetroWebDev Blog Update & Social Bookmarking Tool

With my intent to chart my progress through the Sargasso Sea of .Net development, I decided to update my blog with the new templates/features now offered by Blogger. I'm now taking advantage of the hand-dandy gadgets that are so easily installed, and have integrated the AdSense ads between the posts. (Not that anyone ever clicked on the old AdSense ads, but hope springs eternal.)

One of the things I wanted, and operating under the delusion that people might actually find certain posts here interesting and want to share, was an easy way for visitors to do the social bookmark submission thing.

A quick search took me to AddThis, where I quickly and easily got hold of the handy bookmark button now seen below all posts. You do have to register to get the tool, but heck, I'm registered on a gajillion sites already anyway. What's one more?

So welcome to RetroWebDev's slight new look.

Monday, March 23, 2009

The Inevitable Move to .Net

I don't want to. I've been resisting for years. I'm very fortunate; although my job as a Software Engineering Manager (government sector) requires me to be familiar with the concepts and capabilities of .Net, I've never had to actually write code. Because I am old and lazy and set in my ways, I've continued to use Classic ASP for all my personal projects. When I do dig in to help on a programming, it's usually on the SQL/T-SQL end.

From a development philosophy perspective, I still hold this resolute belief: The User Doesn't Care. All the user wants is to see certain information presented in a certain way after they take a certain action. They couldn't care less about the extension on the end of the filename - .asp, .aspx, .php, .cfm, .html - it just doesn't matter. Show the page, let the user take some sort of action, and show the results as quickly as possible, all using a visually pleasing and easy-to-use interface.

And what are web applications really? Nothing more than a framework for:

putting data in
getting data out

The only people who care about what language is used are developers (because they have a skill and they want a job), and management (because they read in some magazine that language XXX is the thing to use and all the industry is going to it or already on it).

But the time has come to jump int the cesspool of .Net. Why? you ask. Marketability. There are a lot more programming positions out there than there are programming management positions. When the inevitable happens (and sooner or later it will) and I need to find a new job, I need to be able to actually FIND A JOB. And I want to find one without have to relocate.

So....

I'm starting a new project and I'm going to use it as my impetus to learn .Net using C#. Hey, I taught myself Classic ASP and SQL/T-SQL. How hard could it be? Yeah, right....

I'll post here as progress and learn things, things I already know how to do very well, but now have to relearn because someone, somewhere, decided to dump Classic ASP and create .Net. I hope he chokes on a chicken bone.

If I had it to do all over again (and this is my advice to anyone interested in getting into web application development) I recommend the LAMP route:

Linux
Apache
MySQL
PHP

Many big corporations and large sections of the government are still wedded to the Microsoft platform, but even there you can see PHP and other languages making some inroads. Wordpress blogs are all over the place (check out CNNs blogs). Recovery.gov, the new governemnt website about the ongoing financial recovery efforts, is built with the Drupal CMS, which is open source and developed in PHP.

For an out-the-gate, web development programming language, you can't go wrong with PHP. If you decide to expand your skills later, well, you can expand your skills later. But if you don, it will probably be by choice rather than necessity.

Wednesday, March 04, 2009

Kittens Born

I won't bore you with the whole story; suffice to say that the outdoor cat we 'adopted' gave birth to her kittens on Sunday. Welcome to the world!

Friday, January 09, 2009

LinkSys Routers, PASV FTP, and Directory Listing Problems

My router started acted fruity adn I had to replace it. I had an old LinkSys router in the closet, so I pulled it out and hooked it up (I'd replaced it because it had a tendency to drop wireless). All the settings were still there from last time I used it, so everything it came up great. Only problem was when I FTP'd to my server from outside the network, I couldn't get a file listing.

I use a fairly old (and free) version of EasyFTP (which has served me well, hence I've never upgraded), and I hadn't changed anything settings. I could connect, just not get a listing. Passive or active, didn't matter. Much research, various port openings, closing and forwardings later, I still hadn't gotten it to work. But then I read something about how LinkSys returned the IP address of the FTP server when is PASV mode.

I looked in EastFTP's setting under teh settnis for PASV and it was:

IP: 192.168.1.10
Port Range: 1024 - 65535

Under the previous Buffalo router these settings had worked fine. But what I learned was that the LinkSys router was returning the IP as the IP of the server to the EXTERNAL ftp client. So the client was connecting, and then being told to go to 192.168.1.10 to get the file list.

What I tried was changing the IP to match my external WAN IP. Once I did that, my client connected and... returned the file list!

Huzzah!

So if you are running a LinkSys router with an FTP server and you aren't getting your directory/file listing, try setting the PASV IP on your FTP server to match that of you external WAN IP!