3

HELP!!

Just migrating a site from one server to another, the coldfusion version is changing from cf8 to cf9 [linux/centos]

this code used to work before:

cfinclude('../SQL/contact.sql.cfc');
form.phone = unFormatPhone(form.phone);
contactID = InsertContact(form);

In the included file is:

<cfcomponent output="false" >
<!--- -------------------------------- insert -------------------------------- --->
<cffunction name="InsertContact" returntype="numeric" output="false" access="public" >

now I get an error when browsing the pages:

Variable INSERTCONTACT is undefined.


The error occurred in /var/www/vhosts/xxxxxx.com/httpdocs/Assets/XHTML/buy-my-car.cfm: line 54
Called from /var/www/vhosts/newride.ca/httpdocs/Application.cfc: line 232
Called from /var/www/vhosts/newride.ca/httpdocs/Application.cfc: line 230
Called from /var/www/vhosts/newride.ca/httpdocs/Application.cfc: line 162
52 :            cfinclude('../SQL/contact.sql.cfc');
53 :            form.phone = unFormatPhone(form.phone);
54 :            contactID = InsertContact(form);
55 :            
56 :            //insert vehicle with app id

What is going on here? the included file is being found, is there some difference between the two versions that is causing this?

James A Mohler
  • 11,060
  • 15
  • 46
  • 72
Sean Kimball
  • 4,506
  • 9
  • 42
  • 73
  • 2
    Can you pls clarify what you're doing INCLUDING a CFC? I'm surprised that worked on any version of CF. – Adam Cameron Aug 11 '12 at 20:47
  • I guess he is using the cfc as a collection of tools. It does work even on Railo strange as that may seam. – Paul Aug 11 '12 at 22:10
  • Interesting. I really didn't think that was allowed. – Bill Moniz Aug 12 '12 at 01:54
  • Hi @Paul, yeah I get that. I rather more meant "why?". I mean as opposed to using the CFC as it's intended. – Adam Cameron Aug 12 '12 at 07:46
  • It's not my code, looks like the cfc's are mostly invoked but sometimes [like above] are included when someone got lazy. I've moved a couple of these where all you have to do is comment out the cfcomponent tag in the cfc. – Sean Kimball Aug 12 '12 at 15:27

2 Answers2

3

Well, I'll say first off that I've only worked with CF9, so I can't comment on what you used to be able to do in CF8. But, in CF9 I'm pretty sure you cant use a CFC that way. The closest thing to what you're doing would be transient invocation using <cfinvoke>. See here: http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7db3.html

But, also look at instantiating the cfc as an object and then calling methods on that object. I like doing it that way as it reminds me of other languages such as Java and C#.

Bill Moniz
  • 311
  • 1
  • 3
3

Are you sure its being included? try:

include "../SQL/contact.sql.cfc";
form.phone = unFormatPhone(form.phone);
contactID = InsertContact(form);
Paul
  • 1,577
  • 7
  • 10