Sean, First of all this is an advertiser site listed on the site that I am working on. So although I appreciate your comments I have no control on the fact that the spelling is wrong, and that the /pages/default.cfm is being returned by cfhttp.
Sorry I copied the code from Spikes post awhile ago because I was not at the server, so blame him not me. Anyway I managed to get it to work by redirect="true", but that is causing me other areas. All I am trying to do is this, if the site exist then display it. If not then I need to email me an email to say this website (advertiser site had a problem) a little more complicated that this as it needs to do other things but this is the conditions the site can be browsed or it can't, and need to run logic depending on the that condition. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sean Corfield Sent: Saturday, 7 May 2005 12:59 AM To: CFAussie Mailing List Subject: [cfaussie] Re: cfhttp On 5/5/05, Andrew Scott <[EMAIL PROTECTED]> wrote: > I know I asked this question awhile ago, but I am still trying ti find a > solution as to why Coldfusion is not doing this right. It's doing what you ask but there's a couple of errors in your code. BTW, no idea whose site choicecakes is but it has a spelling error in the main headline on the home page: Occaision (should be Occasion). > http://www.choicecakes.com.au is redirected to > pages/default.cfm?page_id=12762 The location value returned is: /pages/default.cfm?page_id=12762 but that's not a valid URL on its own - it needs http://www.choicecakes.com/au prepended to it (which is what a browser does automatically - and what CFMX would do if you specified redirect="true"). > <cffunction name="checkURL"> > <cfargument name="myURL" type="string" required="true" /> > <cfhttp url="#myUrl#" redirect="false" /> > <cfset var sc = left(cfhttp.ResponseHeader.status_code,1)> This can't be your exact code because it doesn't compile. 'var' declarations must appear at the head of the function. Note also that cfhttp is an implicitly created variable so you should 'var' declare that for safety as well or, if you're using CFMX 7, use result= on cfhttp (and 'var' declare your result variable). Furthermore, if the URL being tested does not respond, the ResponseHeader can be an empty struct. You're safer testing isNumber(left(cfhttp.StatusCode,3)) to see if you got a response back (it will not be numeric if the call failed). To debug this, I just added <cfdump var="#cfhttp#"/> immediately after the <cfhttp/> tag. Hope that helps! -- Sean A Corfield -- http://corfield.org/ Team Fusebox -- http://fusebox.org/ Got Gmail? -- I have 50, yes 50, invites to give away! "If you're not annoying somebody, you're not really alive." -- Margaret Atwood --- You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/ --- You are currently subscribed to cfaussie as: [email protected] To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/
