Advertisement

07.31.2008 at 01:13PM PDT, ID: 23612309
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.1

Empty Variable Doesn't Process

Asked by usky1 in ColdFusion Application Server

I have a URL string that I parse then insert information into the database. An example of the string is,
http://1.1.1.1/ind2.cfm?cno=12345&id1=Y1234P&id2=Y12123P&id3=Y22223P&sn1=PSMI&sn2=AFRE&sn3=TGRE
Whenever there is a variable for id1 there will always be one for sn1.
There will always be at least one set.
If there is not a value for a set the id and sn will always be in the string, eg. id1=Y234P&id2=&id3=
If set 2 (id2/sn2) and set 3 (id3/sn3) are left empty I am getting an error,

Incorrect syntax near '='.
SQL = "select * from ib_C where ID ="

The reference is in the code below <!--- Error is here--->

Any help is appreciated.


Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
<!---- loop through the URL and collect up IDs into one variable as a list 1,2,3... ----->
<cfset IDs = "">
 
<cfloop index="ik" from="1" to="3"> 
  <cfif isDefined("url.ID"&ik)> <!--- does it exist and have a value > 0 ? ---->
    <cfset IDs = listAppend(IDs,url['ID'&ik])> <!--- append to the list ---->
  </cfif>
</cfloop>
 
<cfquery name="getSub" datasource="#dssource#">
 SELECT cnum, IID, sf1, sl1, ID
 FROM ib_c
  where ib_c.cnum = <cfqueryparam value="#URL.cno#" cfsqltype="cf_sql_integer">
 <cfif len(IDs)>
  and ib_c.IID in (<cfqueryparam cfsqltype="cf_sql_varchar" list="Yes" value="#IDs#">)
 <cfelse> <!--- no ids found, so return nothing ---->
  and 1=2
 </cfif>
 ORDER BY IID
</cfquery>
 
 
 
<!---- create a list of IDs fetched from the database into one variable ----->
<cfset databaseIDs = valueList(getSchool.IID)>
<!--- <cfoutput>The IDs from the database: #databaseIDs#</cfoutput><br> --->
<cfset listNotFound = "" />
<!--- loop through IDs from the URL and see if they were fetched from the database ----->
<cfloop index="theIID" list="#IDs#">
  <cfif listFindNoCase(databaseIDs,theIID) eq 0> <!---- is ID found in the database? ----->
  	<cfset listNotFound = listAppend(listNotFound, theIID) />
   <!--- ID #theIID# is not in the database.<br> --->
  </cfif>
</cfloop>
<!--- group all id's for cookie --->
<cfset IDs = "">
<cfloop index="i" from="1" to="3">
	<cfif IsDefined("url.id"&i)>
		<cfset intID = Evaluate("url.id"&i)>
		<cfset intID = REReplace(intID, "[^0-9]", "", "all")>
		<cfif intID NEQ "">
			<cfif getSchool.recordcount GT 0>
			<cfquery name="GetChild" datasource="#dssource#">
				select * from ib_c where ID = #intID#
			</cfquery>
			<cfelse>
			</cfif>
			<cfif getSchool.recordcount GT 0>
			<cfloop query="GetChild">
				<cfcookie name="cnum" value="#GetChild.cnum#">
				<cfset IDs = ListAppend(IDs, intID)>
			</cfloop>
			<cfelse>
			<cfset IDs = ListAppend(IDs, intID)>
			</cfif>
		</cfif>
	</cfif>
</cfloop>
 
<!--- group all sn's --->
<cfset SNs = "">
<cfloop index="i" from="1" to="3">
	<cfif IsDefined("url.sn"&i)>
		<cfset intSN = Evaluate("url.sn"&i)>
		<cfif intSN NEQ "">
			<cfif getSchool.recordcount GT 0>
<!--- Error is here--->  <cfquery name="GetChildSN" datasource="#dssource#">
					select * from ib_c where ID = #intID#
				</cfquery>
			<cfelse>
			</cfif>
			<cfif getSchool.recordcount GT 0>
			<cfloop query="GetChildSN">
				<cfset SNs = ListAppend(SNs, intSN)>
			</cfloop>
			<cfelse>
				<cfset SNs = ListAppend(SNs, intSN)>
			</cfif>
		</cfif> 
	</cfif>
</cfloop>
 
<cfset myarray=ListToArray(#listNotFound#, ",")>
<cfset myList = ArrayToList(myArray, ",")>
<!--- output the array as a list --->
 
<cfset myarray=ListToArray(#CGI.QUERY_STRING#, "&")>
<cfloop index="ax" from="1" to="#ArrayLen(myarray)#">
      <!--- <cfoutput>#myarray[ax]#</cfoutput> --->
    <cfset variable=#ListToArray(#myarray[ax]#,"=")#>
</cfloop>
 
<cfset cnum = url.cno>
<cfset fn1 = left(sn1,1)>
<cfset ln1  = mid(sn1,2,len(sn1))>
<cfset fn2 = left(sn2,1)>
<cfset ln2  = mid(sn2,2,len(sn2))>
<cfset fn3 = left(sn3,1)>
<cfset ln3  = mid(sn3,2,len(sn3))>
 
<cfif listFindNoCase(databaseIDs,id1) eq 0>
	<cfset intID = REReplace(id1, "[^0-9]", "", "all")>
	<cfif IsDefined("#id1#") AND id1 EQ GetChild.IID>
	<cfelse>
	<cfquery name="AddStudent1" datasource="#dssource#">
		INSERT INTO ib_c (cnum, ID, IID, parent_email, 
		parent_first, parent_last, sf1, student_grade1, sl1, reason)
		VALUES ('#cnum#', '#intID#', '#id1#','email','pfirst', 'plast','#fn1#', '0', '#ln1#','')
	</cfquery>
	</cfif>
<cfelse>
</cfif>
<cfif listFindNoCase(databaseIDs,id2) eq 0>
	<cfset intID = REReplace(id2, "[^0-9]", "", "all")>
	<cfif IsDefined("#id2#") AND id2 EQ GetChild.IID>
	<cfelse>
	<cfquery name="AddStudent2" datasource="#dssource#">
		INSERT INTO ib_c (cnum, ID, IID, parent_email, 
		parent_first, parent_last, sf1, student_grade1, sl1, reason)
		VALUES ('#cnum#', '#intID#', '#id2#','email','pfirst', 'plast','#fn2#', '0', '#ln2#','')
	</cfquery>
	</cfif>
<cfelse>
</cfif><cfif listFindNoCase(databaseIDs,id3) eq 0>
	<cfset intID = REReplace(id3, "[^0-9]", "", "all")>
	<cfif IsDefined("#id3#") AND id3 EQ GetChild.IID>
	<cfelse>
	<cfquery name="AddStudent3" datasource="#dssource#">
		INSERT INTO ib_c (cnum, ID, IID, parent_email, 
		parent_first, parent_last, sf1, student_grade1, sl1, reason)
		VALUES ('#cnum#', '#intID#', '#id3#','email','pfirst', 'plast','#fn3#', '0', '#ln3#','')
	</cfquery>
	</cfif>
<cfelse>
</cfif>
[+][-]07.31.2008 at 02:16PM PDT, ID: 22133599

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.31.2008 at 03:40PM PDT, ID: 22134174

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.31.2008 at 04:33PM PDT, ID: 22134410

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: ColdFusion Application Server
Sign Up Now!
Solution Provided By: sjaeger949
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.31.2008 at 06:44PM PDT, ID: 22134966

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.01.2008 at 09:09PM PDT, ID: 22143087

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628