cmhampton 8 Junior Poster in Training

Fantastic! That worked perfectly.

$xml->loadXML($assessmentList->GetAssessmentsReturn);

Thank you!!

cmhampton 8 Junior Poster in Training

I get call.stdClass Object ( [GetAssessmentsReturn] => true101 ) which looks right (the actual call returns 101 assessment records).

cmhampton 8 Junior Poster in Training

I think, yes. Basically, I have no way of knowing if it is actually getting the results. I know the service returns them correctly (it's been tested in 3 other languages), so the disconnect must be somewhere in the parsing. If I use:

$soapURL = "http://test.prophecyhealth.com/ProphecyConnect/ProphecyConnectXML.cfc?method=GetAssessments&SecurityCode=A7D5B7D8-73E2-44D2-A6F8-4ACFB91843BF&AssessmentID=-1&AssessmentType=Test";
$assessmentList = file_get_contents($soapURL);
echo $assessmentList;

it will actually dump the correct return content. But I still cannot parse it this way. I have the same problem when get to the $xml->getElementsByTagName("assessment") part.

cmhampton 8 Junior Poster in Training

Hello all,

I am trying to build a client to consume a webservice, and have run into some strange issues. Here is my code:

$securityCode = "A7D5B7D8-73E2-44D2-A6F8-4ACFB91843BF"; // The security code has been changed to an invalid code to prevent unwanted "visitors".
$ProphecyConnect = new SoapClient("http://test.prophecyhealth.com/ProphecyConnect/ProphecyConnectXML.cfc?wsdl");

try
{
    $params = array(SecurityCode => $securityCode, AssessmentID => -1, AssessmentType => "Test");
    $assessmentList = $ProphecyConnect->__soapCall("GetAssessments", array($params));
}
catch(Exception $exception)
{
    var_dump($exception);
}

$xml = new DOMDocument();
$xml->loadXML( $assessmentList );

try
{
    foreach($xml->getElementsByTagName("assessment") as $assessment)
    {
        foreach($assessment->childNodes as $node)
        {
            printf(
            "Name: %s - Type: %s - Value: %s\n",
            $node->nodeName,
            $node->nodeType,
            urlencode($node->nodeValue)     
            );
        }
    }
}
catch(Exception $ex)
{
    echo "Something happened.";
    var_dump($ex);
}

My problem is that the getElementByTagName never finds anything. This is the returned XML from the webservice:

<object>
    <success>true</success>
    <count>3</count>
    <assessments>
        <assessment>
            <assessmentid><![CDATA[201]]></assessmentid>
            <assessmentname><![CDATA[Cardiac Cath Lab V1]]></assessmentname>
            <assessmenttype><![CDATA[Test]]></assessmenttype>
            <costpoints><![CDATA[1]]></costpoints>
            <numberofquestions><![CDATA[23]]></numberofquestions>
            <timelimit><![CDATA[1380]]></timelimit>
        </assessment>
        <assessment>
            <assessmentid><![CDATA[695]]></assessmentid>
            <assessmentname><![CDATA[Cardiac Progressive Care Exam A V1]]></assessmentname>
            <assessmenttype><![CDATA[Test]]></assessmenttype>
            <costpoints><![CDATA[1]]></costpoints>
            <numberofquestions><![CDATA[75]]></numberofquestions>
            <timelimit><![CDATA[4500]]></timelimit>
        </assessment>
        <assessment>
            <assessmentid><![CDATA[708]]></assessmentid>
            <assessmentname><![CDATA[Cardiac Progressive Care Exam B V1]]></assessmentname>
            <assessmenttype><![CDATA[Test]]></assessmenttype>
            <costpoints><![CDATA[1]]></costpoints>
            <numberofquestions><![CDATA[75]]></numberofquestions>
            <timelimit><![CDATA[4500]]></timelimit>
        </assessment>
    </assessments>
</object>

I'm quite the n00b when it comes to PHP, but as far as I can tell, this looks right (at least close). I'm sure I'm missing something blatently obvious though.

Thanks

cmhampton 8 Junior Poster in Training

I need to return a class which inherits List(Of ) in a webservice. The consuming application simply views it as an array of the class, not a list. In fact, the Collection class is not even available to derive an object from.

Class Definition:

Public Class TestResultCollection
  Inherits List(Of TestResult)
End Class

Consuming App:

Dim TestResults As Gateway.TestResultCollection

TestResults = Gateway.GetTestResultsByRequestIDs(secCode, RequestIDs, sError)

Line 1 above will throw an error: Type Gateway.TestResultCollection is not defined.

I realize that I could just use the array instead, but it's not as easy to work with.

Thanks

cmhampton 8 Junior Poster in Training

I've found a "solution". It's not perfect, but it works pretty well. If you use SerializeJSON when returning this data from the ColdFusion web service, it will convert it into a properly formatted JSON string. In this case we are actually returning an array of structures, so instead of serializing the entire object, if you serialize each struct as you append it to the array, it gets returned as a impl:ArrayOf_xsd_anyType SOAP type. .NET has no trouble with this at all. Then there's a couple lines to write in .NET to convert that into objects:

<cfset retArray = ArrayNew(1) />

<cfloop query="queryToProcess">

<cfscript>

tempStruct = StructNew();

StructInsert(tempStruct, "Field1", queryToProcess.field1);
StructInsert(tempStruct, "Field2", queryToProcess.field2);

ArrayAppend(retArray, SerializeJSON(tempStruct));

</cfscript>

</cfloop>
Dim objTemp As Object 'This has to be created as an object instead of an array.
objTemp = WebServiceClass.GetData() 'This would be the web service class created by the Web Reference.

Dim serializer As New JavaScriptSerializer()
Dim theClass As New MyClass()
Dim theCollection As New MyClassCollection() 'These are your class objects
Dim index As Integer = 0

'Loop through each entity in the object
For index = 0 To objTemp.length - 1
theClass = serializer.Deserialize(Of MyClass)(objTemp(index)) 'Deserialize the JSON data
theCollection.Add(theClass) ' Add it to the collection
Next

The important thing here is that the Class created in .NET must have properties named exactly the same as the keys of the structure. Otherwise, they will not map properly.

I hope this helps someone else out there. I searched for hours to find a …

cmhampton 8 Junior Poster in Training

I've found a "solution". It's not perfect, but it works pretty well. If you use SerializeJSON, it will convert it into a properly formatted JSON string. In this case we are actually returning an array of structures, so instead of serializing the entire object, if you serialize each struct as you append it to the array, it gets returned as a impl:ArrayOf_xsd_anyType SOAP type. .NET has no trouble with this at all. Then there's a couple lines to write in .NET to convert that into objects:

<cfset retArray = ArrayNew(1) />

<cfloop query="queryToProcess">

<cfscript>

tempStruct = StructNew();

StructInsert(tempStruct, "Field1", queryToProcess.field1);
StructInsert(tempStruct, "Field2", queryToProcess.field2);

ArrayAppend(retArray, SerializeJSON(tempStruct));

</cfscript>

</cfloop>
Dim objTemp As Object 'This has to be created as an object instead of an array.
objTemp = WebServiceClass.GetData() 'This would be the web service class created by the Web Reference.

Dim serializer As New JavaScriptSerializer()
Dim theClass As New MyClass()
Dim theCollection As New MyClassCollection() 'These are your class objects
Dim index As Integer = 0

'Loop through each entity in the object
For index = 0 To objTemp.length - 1
theClass = serializer.Deserialize(Of MyClass)(objTemp(index)) 'Deserialize the JSON data
theCollection.Add(theClass) ' Add it to the collection
Next

The important thing here is that the Class created in .NET must have properties named exactly the same as the keys of the structure. Otherwise, they will not map properly.

I hope this helps someone else out there. I searched for hours to find a solution and found many others having the same problem, …

cmhampton 8 Junior Poster in Training

I am having issues parsing JSON data from a web service. The web service is local on my machine, and I have added it as a Web Reference. Simple data types from the service work perfectly. However, if I call a method that returns a complex structure (such as an array of structures), the object values are Nothing.

For instance,

Dim ClientOffices As New Object
ClientOffices = NTGateway.GetClientOffices()

gives me an object with 31 item objects, all of which are empty.

This is the data that is returned from the web service method:

[{"Name":"Corporate Office","ID":1},{"Name":"Satellite Office","ID":43},{"Name":"Melville","ID":1370},{"N ame":"Orlando","ID":1383},{"Name":"terry","ID":138 5},{"Name":"marty","ID":1386},{"Name":1.0,"ID":138 7},{"Name":"dallas","ID":1389},{"Name":"Demo Company","ID":1391},{"Name":"Levi","ID":1436},{"Na me":"Broward","ID":1439},{"Name":"Morgan","ID":150 5},{"Name":"Scott","ID":1623},{"Name":"Katie","ID" :1625},{"Name":"Miami","ID":2183},{"Name":"Adapt", "ID":2190},{"Name":"High Point","ID":2604},{"Name":"Chicago","ID":2612},{"N ame":"jim","ID":2647},{"Name":"Hawaii","ID":2666}, {"Name":"Custom Solutions","ID":2669},{"Name":"Tina","ID":2886},{" Name":"Greensboro","ID":3027},{"Name":"Melissa","I D":3799},{"Name":"High Point","ID":3815},{"Name":"Education","ID":3996},{ "Name":"Med Surg","ID":3997},{"Name":"ER","ID":3998},{"Name":" critical care","ID":3999},{"Name":"Critical care","ID":4103},{"Name":"Main Office","ID":4192}]

It works if I use a jQuery parser, but I can't seem to get the same results in VB.

Thanks

cmhampton 8 Junior Poster in Training

Has anyone ever tried returning a ColdFusion structure through a web service? The WSDL type CF assigns to this is apachesoap:Map, but when I consume this in VB.NET, the data is null.

I have converted the entire thing into a JSON string, and that seems to work, but it requires a ton of code on the .NET side to handle. We are trying to do this with a minimal amount of work for our customers.

Thanks

cmhampton 8 Junior Poster in Training

You would probably have to loop through the resultset and assign each row to an array; you can't just split the resultset;
it might be easier/faster to just have to queries with their own resultset

I figured that was the case, but wanted to make sure before I gave up.

Thanks.

cmhampton 8 Junior Poster in Training

Hi all,

I'm helping a friend redo his database queries and have run into something that I need some advice on. Let me first say that I am not a PHP developer, so please bear with me.

I have two queries that I can merge together, but I will need to separate the data later. For example, let's say I have a book collection section of my site. It allows users to rate books and optionally write a review. What I would like to do is get all this data in one query (I already have the query for this) and then 'query' the recordset to split the results, those who reviewed the book and those who only rated it.

Is this possible in PHP? I've done it in other languages, but not being a PHP developer, I have no idea where to start.

Thanks in advance.

cmhampton 8 Junior Poster in Training

I figured out what this was.

Security permissions on the cfc folder were blocking ajax requests. What I was getting in response was my site's 404 page.

So in other words, I'm stupid. lol

cmhampton 8 Junior Poster in Training

I recently updated our servers to CF 8.0.1 and now none of my AJAX code works. I checked the XHR response in Firebug and instead of returning the requested data, it returns the HTML code for my site's home page.

All of this was working before the update and I have not changed any code. Has anyone else seen this before?

Thanks

cmhampton 8 Junior Poster in Training

Here's something to start with. To get the first four characters of the user's name, use the LEFT function. Assuming you have a text box on the form called 'txtName':

<cfset username = LEFT(form.txtName, 4) />

If the name entered in that field was 'mkwebnovice', this would give you 'mkwe'. Next, you can use the MAX function in SQL (provided you are using SQL) to get the highest ID record in your user's table. I am of course assuming that you have a users table with an auto incrementing id field. When you do your insert statement, use this function and combine it with the result of the LEFT function above.

<cfquery datasource="whatever your datasource is" name="qryGetMaxUserID">
  DECLARE @userID varchar(10);
  SELECT @userID = CAST((SELECT MAX(userID) + 1 AS newUserID FROM users) AS varchar(10));

  INSERT
    users
    (
       username
    )
VALUES
    (
      '#username#' + @userID
    )
</cfquery>

If you a user table and the last userID is 20, this will result in a username of 'mkwe21'.

I hope this helps.

cmhampton 8 Junior Poster in Training

Anytime. Glad to help.

cmhampton 8 Junior Poster in Training

You need to create the datasource in the ColdFusion administrator if you have access to it.

cmhampton 8 Junior Poster in Training

Here goes. There's a lot here, so bear with me. This is actually two custom tags. One to set the variables and one to create the links.

Here is the first custom tag:

<!--- pageNumSetup.cfm --->

<cfscript>
	// round page number variable up
	function roundPageNum(number) {
		
		var x = 0;
		
		x = Int(number);
		
		if(number - x neq 0) {
			x = x + 1;
		}
		
		return x;
	}
</cfscript>

<!--- Set Default values --->
<cfparam name="Caller.startRow" default="1">
<cfparam name="Caller.nextPage" default="">
<cfparam name="Caller.prevPage" default="">
<cfparam name="Caller.numPerPage" default="20">
<cfparam name="Caller.numPages" default="0">
<cfparam name="Caller.curPage" default="1">
<cfparam name="Attributes.queryName" default="">

<!--- Set values for previous and next pages --->
<cfset Caller.nextPage = Caller.startRow + Caller.numPerPage>
<cfset Caller.prevPage = Caller.startRow - Caller.numPerPage>

<!--- Determine the total number of pages for this search --->
<cfset Caller.numPages = Attributes.queryName.RecordCount / Caller.numPerPage >
<cfset Caller.numPages = roundPageNum(Caller.numPages)>
<cfset Caller.curPage = ((Caller.startrow -1) / Caller.numPerPage) + 1>

Now for the navigation links:

<!--- pageNum.cfm --->

<!--- Set Default values --->
<cfparam name="Caller.startRow" default=""> <!--- Numeric --->
<cfparam name="Caller.nextPage" default=""> <!--- Numeric --->
<cfparam name="Caller.prevPage" default=""> <!--- Numeric --->
<cfparam name="Caller.numPerPage" default="20"> <!--- Numeric --->
<cfparam name="Caller.numPages" default=""> <!--- Numeric --->
<cfparam name="Caller.curPage" default=""> <!--- Numeric --->
<cfparam name="Caller.queryName" default=""> <!--- Query --->
<cfparam name="Attributes.forwardImage" default=""> <!--- string --->
<cfparam name="Attributes.backImage" default=""> <!--- string --->

<!--- This variable is used to direct the links to the correct template --->
<cfparam name="Attributes.pageName" default="Index.cfm">  <!--- string --->

<!--- If there is only one page of results, there is no need to show …
cmhampton 8 Junior Poster in Training

OK. I have a custom tag that will pretty much do everything for you. I'll post it in the morning when I get back to work.

cmhampton 8 Junior Poster in Training

Are you permitted by your hosting company to use custom tags?

cmhampton 8 Junior Poster in Training

Based on query data? If so yes, but I don't have it with me at the moment. I'll get back to you.

cmhampton 8 Junior Poster in Training

Can you give me a little more information about what this particular query is trying to do? You may not need to use UNION, but perhaps different JOINs.

cmhampton 8 Junior Poster in Training

Thanks! But I have also used != and the result is still the same :(

Can you make up some sample data for me? I'll recreate this structure on my server and test it.

cmhampton 8 Junior Poster in Training

Try using != (not equal) instead of NOT LIKE. LIKE is a little more 'fuzzy' than an explicit equal, which is why you did not get the data you were looking for.

Also, one other thing that might help make your queries easier to read (and type) is using aliases for your tables:

SELECT 
		r.[Officer ID],
		r.[Plate Number],
		r.[Violation Commited],
		v.[Violation Code],
		r.[Street Name],
		r.[City of Apprehension],
		r.[Vehicle Category],
		r.[Vehicle Type],
		r.[Vehicle Brand],
		r.[Date/Time Apprehended]
FROM 
		Records r,
		Violations v,
		DriverInfo di
WHERE 
		r.[Plate Number] != di.[Plate Number]
		and r.[Violation Commited] = v.Violations

I hope this helps.

cmhampton 8 Junior Poster in Training

Try this:

SELECT 
		hourStamp,
		NULL AS ActualVisits,
		SUM(CASE WHEN datestamp < GETDATE() THEN 1 ELSE 0 END) / @numberofdays as HourAverage, 
		SUM(CASE WHEN dateStamp BETWEEN DATEADD(d,DATEDIFF(d,0,GETDATE()),0) AND GETDATE() THEN 1 ELSE 0 END) as HourToday
FROM 
		webstats
GROUP BY 
		hourStamp

UNION

SELECT 
		hourstamp, 
		COUNT(id) AS ActualVisits,
		NULL AS HourAverage,
		NULL AS HourToday
FROM 
		webStats
WHERE 
		id IN                            
		(SELECT ws.id
		FROM webStats AS ws INNER JOIN webStatsTrace AS wst ON ws.id = wst.statsid
		WHERE (ws.datestamp BETWEEN DATEADD(d, DATEDIFF(d, 0, GETDATE()), 0) AND GETDATE())
		GROUP BY ws.id HAVING (COUNT(wst.statsid) > 1))
GROUP BY 
		hourstamp
ORDER BY 
		hourstamp

Use aliased NULLs to make the SELECT clauses of the two queries match.

cmhampton 8 Junior Poster in Training

If you are using SQL 2005, here's another option. (originally posted in http://www.daniweb.com/forums/post639423-7.html)

Suppose you have a table with the following structure:

id - int PrimaryKey
name - varchar(50)
description - varchar(MAX)

and the following values:

1	Joe	  Short for Joseph
2	Dave	  Short for David
3	Joe	  Short for Joseph
4	Joe	  Short for Joseph
5	Chris	  Short for Christian
6	Rob	  Short for Robert

Notice that "Joe - Short for Joseph" has three duplicate records. It is true that we can use SELECT DISTINCT to filter these, and for a simple table like this, that's probably the best option. However, sometimes SELECT DISTINCT gets a little hairy when dealing with joins, at least in my experience. So, without having the time to create a complex data structure, or using one I already have that contains confidential data, let's use this simple example.

MSSQL 2005 added a handy new function called ROW_NUMBER(). Learn it, love it (lol). Seriously though, it will make your life easier. What this function does is allow you to get the row number of a record in a returned data table. On the surface, this doesn't sound like much. But, it becomes extremely useful when you realize that you can partition, or group, the records. Let use this on the table shown above:

WITH names AS 
(
SELECT
		id,
		name,
		description,
		ROW_NUMBER() OVER(PARTITION BY name, description ORDER BY id) AS rowNum
FROM
		table_1
)

SELECT
		id,
		name,
		description, …
cmhampton 8 Junior Poster in Training

http://www.paulschou.com/tools/iso8859.html has a pretty comprehensive list. It's a lot to wade through, but you'll probably never need to look anywhere else.

BTW, is this for an engineering publication? Just out of curiosity...

cmhampton 8 Junior Poster in Training

Found it!

This will replace 67 special characters with their HTML equivalent. I've used this to generate RSS feeds before, so it should work just fine for you.

<cffunction name="formatXML" access="public" returntype="string">
		<cfargument name="strString" required="yes" default="">
		
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("192", 16))#", "&fnof;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("391", 16))#", "&Alpha;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("392", 16))#", "&Beta;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("393", 16))#", "&Gamma;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("394", 16))#", "&Delta;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("395", 16))#", "&Epsilon;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("396", 16))#", "&Zeta;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("397", 16))#", "&Eta;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("398", 16))#", "&Theta;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("399", 16))#", "&Iota;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("39A", 16))#", "&Kappa;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("39B", 16))#", "&Lambda;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("39C", 16))#", "&Mu;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("39D", 16))#", "&Nu;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("39E", 16))#", "&Xi;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("39F", 16))#", "&Omicron;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("3A0", 16))#", "&Pi;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("3A1", 16))#", "&Rho;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("3A3", 16))#", "&Sigma;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("3A4", 16))#", "&Tau;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("3A5", 16))#", "&Upsilon;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("3A6", 16))#", "&Phi;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("3A7", 16))#", "&Chi;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("3A8", 16))#", "&Psi;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("3A9", 16))#", "&Omega;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("3B1", 16))#", "&alpha;", "all")>
		<cfset strString = ReplaceNoCase(strString, "#chr(inputbasen("3B2", …
cmhampton 8 Junior Poster in Training

Go into the ColdFusion Administrator and turn on Robust Debugging. Check the line number and let me know where the error is occurring. I didn't get a chance to actually test this, so I probably missed something.

cmhampton 8 Junior Poster in Training

Couple of things here:

Use CFFILE to upload the files to the server.

(http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_f_02.html#4003197)

You also need to change the form's encoding type to multipart. I have updated your code below:

<cfset CurrentPage=GetFileFromPath(GetBaseTemplatePath())>
<cfif IsDefined("FORM.MM_InsertRecord") AND FORM.MM_InsertRecord EQ "form1">

	<!--- Set the destination folder.  Use ExpandPath to properly map the folder. --->
	<cfset filePath = ExpandPath("/uploads") />

	<!--- Upload the image file.  Notice that the fileField value is not enclosed in #s.  This is the correct syntax --->
	<cffile action="upload" filefield="form.imageFile" nameconflict="makeunique" destination="#filePath#" result="imageUpload" />
	
	<!--- Upload the brochure file. --->
	<cffile action="upload" filefield="form.brochureFile" nameconflict="makeunique" destination="#filePath#" result="brochureUpload" />

	<cfquery datasource="affinity">   
		INSERT INTO 
				vehicle_details 
				(vehicle_description, contract_details, available_to, deposit, business_price, personal_price, additional_infomation, manufacturer, imageFile, brochureFile)
		VALUES (
				<cfif IsDefined("FORM.vehicle_description") AND FORM.vehicle_description NEQ "">
					<cfqueryparam value="#FORM.vehicle_description#" cfsqltype="cf_sql_clob" maxlength="200">
				<cfelse>
					''
				</cfif>,
				<cfif IsDefined("FORM.contract_details") AND FORM.contract_details NEQ "">
					<cfqueryparam value="#FORM.contract_details#" cfsqltype="cf_sql_clob" maxlength="150">
				<cfelse>
					''
				</cfif>,
				<cfif IsDefined("FORM.available_to") AND FORM.available_to NEQ "">
					<cfqueryparam value="#FORM.available_to#" cfsqltype="cf_sql_clob" maxlength="45">
				<cfelse>
					''
				</cfif>,
				<cfif IsDefined("FORM.deposit") AND FORM.deposit NEQ "">
					<cfqueryparam value="#FORM.deposit#" cfsqltype="cf_sql_clob" maxlength="45">
				<cfelse>
					''
				</cfif>,
				<cfif IsDefined("FORM.business_price") AND FORM.business_price NEQ "">
					<cfqueryparam value="#FORM.business_price#" cfsqltype="cf_sql_clob" maxlength="45">
				<cfelse>
					''
				</cfif>,
				<cfif IsDefined("FORM.personal_price") AND FORM.personal_price NEQ "">
					<cfqueryparam value="#FORM.personal_price#" cfsqltype="cf_sql_clob" maxlength="45">
				<cfelse>
					''
				</cfif>,
				<cfif IsDefined("FORM.additional_infomation") AND FORM.additional_infomation NEQ "">
					<cfqueryparam value="#FORM.additional_infomation#" cfsqltype="cf_sql_clob" maxlength="45">
				<cfelse>
					''
				</cfif>,
				<cfif IsDefined("FORM.manufacturer") AND FORM.manufacturer NEQ "">
					<cfqueryparam value="#FORM.manufacturer#" cfsqltype="cf_sql_clob" maxlength="45">
				<cfelse>
					''
				</cfif>,
				<cfif IsDefined("imageUpload") AND Len(Trim(imageUpload)) NEQ 0>
					<cfqueryparam value="#imageUpload.ServerFile#" cfsqltype="cf_sql_varchar">
				<cfelse>
					''
				</cfif>,
				<cfif IsDefined("brochureUpload") AND Len(Trim(brochureUpload)) NEQ 0>
					<cfqueryparam value="#brochureUpload.ServerFile#" cfsqltype="cf_sql_varchar">
				<cfelse>
					''
				</cfif>
			)
	</cfquery> …
cmhampton 8 Junior Poster in Training

I have a CFC method somewhere that replaces around 30 commonly used symbols. If I can find it, I'll post it.

cmhampton 8 Junior Poster in Training

Strange. You may need to replace it with &deg;, still inside the cdata. I don't remember the ascii codes for the decimal character, but I'm sure that's pretty easy to find.

cmhampton 8 Junior Poster in Training

Wrap your content inside a <![CDATA[ ]]> tag. XML will ignore any special characters inside.

<instrumentation.InstrRange><![CDATA[-40° to 70°C]]></instrumentation.InstrRange>
cmhampton 8 Junior Poster in Training

I'm not aware of any way to get this to work in CF. However, in your SQL query/stored procedure, you could put the data into temp tables, join them there and then return the results to CF. This would eliminate the need for QoQ joins.

Let me know if you want some help doing that.

cmhampton 8 Junior Poster in Training

Sorry I didn't get this uploaded the other night, the kids have been sick.

Suppose you have a table with the following structure:

id - int PrimaryKey
name - varchar(50)
description - varchar(MAX)

and the following values:

1	Joe	  Short for Joseph
2	Dave	  Short for David
3	Joe	  Short for Joseph
4	Joe	  Short for Joseph
5	Chris	  Short for Christian
6	Rob	  Short for Robert

Notice that "Joe - Short for Joseph" has three duplicate records. It is true that we can use SELECT DISTINCT to filter these, and for a simple table like this, that's probably the best option. However, sometimes SELECT DISTINCT gets a little hairy when dealing with joins, at least in my experience. So, without having the time to create a complex data structure, or using one I already have that contains confidential data, let's use this simple example.

MSSQL 2005 added a handy new function called ROW_NUMBER(). Learn it, love it (lol). Seriously though, it will make your life easier. What this function does is allow you to get the row number of a record in a returned data table. On the surface, this doesn't sound like much. But, it becomes extremely useful when you realize that you can partition, or group, the records. Let use this on the table shown above:

WITH names AS 
(
SELECT
		id,
		name,
		description,
		ROW_NUMBER() OVER(PARTITION BY name, description ORDER BY id) AS rowNum
FROM
		table_1
)

SELECT
		id,
		name,
		description,
                rowNum …
cmhampton 8 Junior Poster in Training

The script is on a different computer. I'll post it when I get home.

cmhampton 8 Junior Poster in Training

What version of MSSQL are you using? If 2005, then I have a query you can modify that will remove duplicate entries.

cmhampton 8 Junior Poster in Training

Thank you, cmhampton !
How about cfquery: "result" ?What you prefer?
H.

I'm not sure I understand your question.

cmhampton 8 Junior Poster in Training

I'm glad I could help. Please mark the thread solved.

cmhampton 8 Junior Poster in Training

Is it possible to 'replace' more than one, {Name} {SURNAME}

You can use a second Replace function:

<cfset mailBody = Replace(#form.body#, "{NAME}", #rsSubscribersMail.name#, "all") />
<cfset mailBody = Replace(#mailbody#, "{SURNAME}", #rsSubscribersMail.surname#, "all") />
cmhampton 8 Junior Poster in Training

When you use a variable in the list element of the CFLOOP tag, it must be enclosed in #'s...

<cfset myd = "">
<cfloop list="#form.mydata#" index="i" delimiters=",">
  <cfoutput>
   <cfset myd = "#i#">
   #myd#<br />
 </cfoutput>
</cfloop>

Otherwise, it interprets it as a literal value.

cmhampton 8 Junior Poster in Training

You need to cfloop through the query.

<cfquery name="rsSubscribersMail" datasource="DATA">
SELECT subscriber.subscriberID, subscriber.name, subscriber.surname, subscriber.email
FROM subscriber
</cfquery>

<cfloop query="rsSubscribersMail">

  <cfset mailBody = Replace(#form.body#, "{NAME}", #rsSubscribersMail.name#, "all") />

  <cfmail to="#rsSubscribersMail.email#" from="#form.from#" subject="#form.subject#" server="127.0.0.1" port="25">
  #mailBody#
  </cfmail>

</cfloop>

If you don't loop through the query, it will always use the values from the first record.

cmhampton 8 Junior Poster in Training

I have used the cfmail tag alot but dont get the following to work. I have a form were a system administrator can submit a email to all subscribers informing them of 'something', whatever.

My problem is, the text area field is being used for the body of the mail being send via cfmail query

How do I transform the {NAME} inside the textare to the users real name when the cfmail page process the textarea content.

<textarea name="body" cols="30" rows="4" id="body">Dear {NAME}, welcome to our site.</textarea> <-- This gets pass onto the cfmail page for processing?

You can string replace the {NAME} with the user's name (which I assume is on a form somewhere). For example:

<cfset mailBody = Replace(form.body, "{NAME}", form.name, "all") />
cmhampton 8 Junior Poster in Training

In a typical situation, yes, that should be all you need. Provided of course the pages do what they are supposed to.

Of course, your situation may or may not be typical. At this point I would suggest some simple testing to see how it works.

cmhampton 8 Junior Poster in Training

That's not so much a coldfusion problem as it is an SQL "feature". Floats are not exact representations of numbers, but approximates. Here's an explanation: http://msdn.microsoft.com/en-us/library/ms173773.aspx

In your query, you should be able to CAST the float into another datatype, such as a decimal and that should solve your problem.

For example:

DECLARE @float float;
DECLARE @casted decimal(18,10);
SET @float = 10000000 / 7.65;

PRINT @float

SET @casted = CAST(@float AS decimal(18,10))

PRINT @casted

This is MSSQL, but I would imagine the Centura syntax would be similar. It should return:

1.30719e+006
1307189.5424830001

The first number is the approximate representation from the float, and the second is the exact value in decimal.

I hope that helps.

cmhampton 8 Junior Poster in Training

I'm sorry. I'd love to help you with that but I've never used cfexchangemail. Do you know what the special characters are? If so, perhaps you could strip them from the UID before you pass it to the cfexchangemail tag.

Other than that, I really don't have any ideas.

cmhampton 8 Junior Poster in Training

Here's one way:

Get your db information before you output the <head> tag on your page.

Inside the <title> tag, output the info from your query. For example:

<cfquery datasource="dsn" name="pageData">
  SELECT
              *
  FROM
              pageContent
  WHERE
             pageID = #pageID#
</cfquery>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><cfoutput>#pageData.Title#</cfoutput></title>
</head>

Obviously, replace the query with your own, but you get the general idea?

Let me know if you need more help.

cmhampton 8 Junior Poster in Training

Are you saying that the insert.cfm page is missing?

If so, do you have any information (table structures, etc..) so it can be recreated? I'm more than happy to help if you can give me more info.

cmhampton 8 Junior Poster in Training

Not being able to see the code, I don't have any concrete solutions, but it may be an issue with cookies. If you are able to cancel the second login screen and still get it, that leads me to believe that the authentication page may not be seeing the cookies correctly. I suppose it's possible that it's a mac issue, but I would recommend looking at the cookies first.

If you have a user with Firefox, please have your web programmer install a Firefox addon called WebDeveloper. This will let him get detailed information about the cookies and even set his own for testing. Then he might be able to narrow down the problem.

Sorry I can't be more help.

cmhampton 8 Junior Poster in Training

Use SCOPE_IDENTITY(). It will return the id of the record just created, provided the field is set as the identity column.

<cffunction name="insertData" access="public">
  <cfargument name="formData" type="struct" required="yes">
  
  <cfquery name="qInsert" datasource="mydata">
       INSERT INTO mytable
          (email, firstname, name)
       VALUES
          ('#formData.email#', '#formData.firstname#', '#formData.name#')

       SELECT id = SCOPE_IDENTITY()
   </cfquery>

   <cfreturn qInsert.id />

</cffunction>
cmhampton 8 Junior Poster in Training

You don't technically need any version to code for it, it isn't like Visual Studio. You can code in pretty much any text editor.

But to answer your question, if you are going to buy a new copy of Dreamweaver, then CS3 is the latest version available. I believe that any version after 6 supports the new tags added to MX 7, so if you can get an older version cheaper then get CS or CS2.

Does that make sense?