Confused Newbie

admin

Administrator
Staff member
Hi all,

I have inherited some XML that does a postcode lookup. When I run it on my local system it works perfectly but when I upload it to the server for final testing before release it displays part of a html page instead.

Here is the code, this first bit are the fields to be updated:

<form action="PageEnd.asp" method="post" name="RHAScript">
<table cellSpacing=0 cellPadding=0 border=0>
<tr>
<td class="Text_10" width="100">Number/ Street:&nbsp;</td>
<td colspan="2"><input name="HouseNumber" size=38 maxlength="250" class="FormBox" value=http://www.webdeveloper.com/forum/archive/index.php/"<%=QuestionAnswers_Address_HouseNumber%>"></td>
</tr>
<tr>
<td class="Text_10">City:&nbsp;</td>
<td colspan="2"><input name="City" size=38 maxlength="50" class="FormBox" value="<%=QuestionAnswers_Address_City%>"></td>
</tr>
<tr>
<td class="Text_10">County:&nbsp;</td>
<td colspan="2"><input name="County" size=38 maxlength="50" class="FormBox" value="<%=QuestionAnswers_Address_County%>"></td>
</tr>
<tr>
<td class="Text_10">Postcode:&nbsp;</td>
<td><input name="Postcode" size=28 maxlength="10" class="FormBox" value="<%=QuestionAnswers_Address_Postcode%>"></td>
<td valign="top" al ign="right"><a href="#" id=PostcodeLookup name="PostcodeLookup" onclick="getAd()"><img src="images/button_lookup.png" border="0"></a></td>
</tr>
</table>
</form>


Here is the function the button calls and the xml:

sub getAd
Set xml = CreateObject("Microsoft.XMLHTTP")

// Opens the connection to the remote server.
xml.Open "GET", "functions/getAddr.asp?PC=" & Replace(RHAScript.Postcode.Value," ",""), False

// Actually Sends the request and returns the data:
xml.Send

// Display the HTML both as HTML and as text
myarr = Split(xml.responseText,",")
if myarr(0) = "-1" then
msgbox "Address not found!"
else
RHAScript.Postcode.value = UCase(Replace(RHAScript.Postcode.Value," ",""))
RHAScript.HouseNumber.value = myarr(0)
RHAScript.City.Value = myarr(1)
RHAScript.County.Value = myarr(2)
end if
Set xml = Nothing
End Sub


And here is the function that that piece of code called:

Dim conn,cm, parm
Set conn = Server.CreateObject("ADODB.Connection")
Set cm = Server.CreateObject("ADODB.Command")'Set rs = Server.CreateObject("ADODB.RecordSet")
'conn.Open "Driver={SQL Server}; Server=jamz; Database=ora; UID=sa; PWD=;"
conn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MotionDat;Data Source=zeus;"

'Get address
cm.ActiveConnection = conn
cm.CommandText = "getAddr"

' 4 is Stored Procedure
cm.CommandType = 4
Set parm = cm.CreateParameter ("@PC",200,1,7)
cm.Parameters.Append parm
cm.Parameters("@PC")=Request.QueryString("PC")

set rs = cm.Execute
if rs.EOF then
Response.Write "-1"
else
Response.Write rs(0) + ","
Response.Write rs(1) + ","
Response.Write rs(2) + ","
Response.Write rs(3)
end if


Here is the output the way it's supposed to look:

House Number / Street : Pond Street
City :
County : Sheffield
Postcode : S1 1AA


This is what is produced on the server version:

House Number / Street : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html dir=ltr><head><style>a:link {font:8pt/11pt verdana; color:FF0000}a:visited {font:8pt/11pt verdana; color:#4e4e4e}</style><META NAME="ROBOTS" CONTENT="NOINDEX"><title>The page cannot be displayed</title><META HTTP-EQUIV="Content-Type" Content="text-html; charset=Windows-1252"></head><script> function Homepage(){<!--// in real bits

City : urls get returned to our script like this:// <!-- m --><a class="postlink" href="res://shdocvw.dll/http_404.htm#http://www.DocURL.com/bar.htm">res://shdocvw.dll/http_404.htm#http://w ... om/bar.htm</a><!-- m --> //For testing use DocURL = "res://shdocvw.dll/http_404.htm#https://www.microsoft.com/bar.htm" DocURL=document.URL; //this is where the http or https will be

County : as found by searching for :// but skipping the res:// protocolIndex=DocURL.indexOf("://"

Postcode : S1 1AA

Sorry this is so long and thank you if you are still reading this. Why is it doing this? Is XML not to be run via a server, and if so how do you ever display pages? Does the code need to be change to make it compatible?

I would like to get this working and any help would be greatfully received, if not I will have to scrap it and start again, which is a shame since it does work on my local version.

Thanks again,
Taiya :confused:
 
Back
Top