ASP到PHP [英] ASP to PHP

查看:65
本文介绍了ASP到PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我在ASP中有这个页面,它输入一个输入的邮政编码并显示该区域的适当详细信息,我需要将其翻译成PHP。有人可以帮忙吗?

我正在使用MySQL数据库。感谢您提供的任何帮助,非常感谢。


函数RemoveWhiteSpace(strText)''删除白色的功能邮政编码空格

Dim RegEx

设置RegEx =新RegExp

RegEx.Pattern =" \s +"

RegEx.Multiline = True

RegEx.Global = True

strText = RegEx.Replace(strText,"")

RemoveWhiteSpace = strText

结束功能

Dim nptCode,nptDistrict,noVals,origPostCode

origPostCode = Request .Form(postcode)''不改变这个值


If(origPostCode<>"")然后''我们来自邮政编码搜索页面


Dim cleanPostCode,wiltsCode


wiltsCode = False''这是一个wiltshire邮政编码(见选择声明)

cleanPostCode = UCase(RemoveWhiteSpace(origPostCode))


选择Case Left(cleanPostCode,2)

CaseBA,SN,SP,GL,RG

wiltsCode = True

Case Else

Response.Redirect(" postcodesearch.asp?e = nw& pcode =" & Request.Form(" postcode")&"")''转到带有网址扩展的帖子代码错误页面(nw:not wiltshire)

结束选择


if(wiltsCode)那么

Dim rs_pcode

Dim rs_pcode_cmd

Dim rs_pcode_numRows


设置rs_pcode_cmd = Server.CreateObject(" ADODB.Command")

rs_pcode_cmd.ActiveConnection = MM_maincms_STRING

rs_pcode_cmd.CommandText =" SELECT npt_code,dis_name FROM q_npt_pcodes WHERE UCASE(pc_postcode)=?"

rs_pcode_cmd.Prepared = true

rs_pcode_cmd.Parameters.Append rs_pcode_cmd.CreateParameter(" param1",200,1,10,cleanPostCode)''adVarChar


设置rs_pcode = rs_pcode_cmd.Execute

rs_pcode_numRows = 0

如果(rs_pcode.BOF或rs_pcode.EOF)那么

Response.Redirect(" postcodesearch.asp?e = nf& pcode ="& Request.Form(" postcode")&"")''转到带有网址扩展的帖子代码错误页面( nf:not found)

Else

nptCode =(rs_pcode.Fields.Item(" npt_code")。Value)

nptDistrict =( rs_pcode.Fields.Item(" dis_name")。Valu e)


Dim MM_editCmd

设置MM_editCmd = Server.CreateObject(" ADODB.Command" )

MM_editCmd.ActiveConnection = MM_maincms_STRING

MM_editCmd.CommandText =" INSERT INTO t_pcode_searches(pcsearch_pc,pcsearch_outcome,pcsearch_stam p,pcsearch_ip)VALUES(?,?,?,?)"

MM_editCmd.Prepared = true

MM_editCmd.Parameters.Append MM_editCmd.CreateParameter(" param1",202,1,10,Request.Form(" postcode")) )''adVarWChar

MM_editCmd.Parameters.Append MM_editCmd.CreateParameter(" param2",202,1,10," ok")''adVarWChar

MM_editCmd。 Parameters.Append MM_editCmd.CreateParameter(" param3",135,1,50,Now())''date

MM_editCmd.Parameters.Append MM_editCmd.CreateParameter(" param4",202,1 ,50,Request.ServerVariables(" REMOTE_ADDR"))''adVarWChar

MM_editCmd.Execute

MM_editCmd.ActiveConnection.Close

结束如果

结束如果


其他''我们来自地图页面


''获取网址params

nptCode = UCase(Request.QueryString(" id"))

nptDistrict = LCase(Request.QueryString(" district"))

''将区域设置为正确值

选择案例nptDistrict

案例salisbury

nptDistrict =" Salisbury" ;

案例swindon

nptDistrict =" Swindon"

案例" nwilts"

nptDistrict =北威尔特郡

案例wwilts

nptDistrict =" West Wiltshire"

Case" kennet"

nptDistrict =" Kennet"

Case Else

nptDistrict =""

End Select


结束如果


''设置变量来检查我们有我们需要的一切(稍后使用)

If(nptCode =" "或者nptDistrict ="")然后

novals = True

结束如果



Dim xmlDoc

设置xmlDoc = Server.CreateObject(" Microsoft.XMLDOM")

xmlDoc.async = false

xmlDoc.load(Server.MapPath(") ; xml / nptdata.xml"))

xmlDoc.setProperty" SelectionLanguage"," XPath"

如果xmlDoc.parseError.errorcode<> 0然后

Response.Write(xmlDoc.parseError.errorcode)

Response.Write("< / br>处理xml文件时出错)


结束如果



nodepath =" / NPTInfo / District [@DistrictName =''"& nptDistrict&"''] / NPT [@NPTCode =''"& nptCode&"'']"

%>

Hi. i have this page in ASP that pulls an entered postcode and displays the apropriate details for that area and i need to translate it into PHP. can anyone help?
Im using a MySQL database.thank you for any help that you can give, much appreciated.

Function RemoveWhiteSpace(strText) ''function to remove white spaces from post code
Dim RegEx
Set RegEx = New RegExp
RegEx.Pattern = "\s+"
RegEx.Multiline = True
RegEx.Global = True
strText = RegEx.Replace(strText, "")
RemoveWhiteSpace = strText
End Function

Dim nptCode, nptDistrict, noVals, origPostCode

origPostCode = Request.Form("postcode") ''do not alter this value

If (origPostCode <> "") Then ''we''ve come from the postcode search page

Dim cleanPostCode, wiltsCode

wiltsCode=False ''is it a wiltshire post code (see select statement)
cleanPostCode = UCase(RemoveWhiteSpace(origPostCode))

Select Case Left(cleanPostCode,2)
Case "BA", "SN", "SP", "GL", "RG"
wiltsCode=True
Case Else
Response.Redirect("postcodesearch.asp?e=nw&pcode=" &Request.Form("postcode")&"")''go to post code error page with url extention (nw: not wiltshire)
End Select

If(wiltsCode)Then
Dim rs_pcode
Dim rs_pcode_cmd
Dim rs_pcode_numRows

Set rs_pcode_cmd = Server.CreateObject ("ADODB.Command")
rs_pcode_cmd.ActiveConnection = MM_maincms_STRING
rs_pcode_cmd.CommandText = "SELECT npt_code, dis_name FROM q_npt_pcodes WHERE UCASE(pc_postcode) = ?"
rs_pcode_cmd.Prepared = true
rs_pcode_cmd.Parameters.Append rs_pcode_cmd.CreateParameter("param1", 200, 1, 10, cleanPostCode) '' adVarChar

Set rs_pcode = rs_pcode_cmd.Execute
rs_pcode_numRows = 0
If(rs_pcode.BOF OR rs_pcode.EOF)Then
Response.Redirect("postcodesearch.asp?e=nf&pcode=" &Request.Form("postcode")&"")''go to post code error page with url extention (nf: not found)
Else
nptCode=(rs_pcode.Fields.Item("npt_code").Value)
nptDistrict=(rs_pcode.Fields.Item("dis_name").Valu e)

Dim MM_editCmd
Set MM_editCmd = Server.CreateObject ("ADODB.Command")
MM_editCmd.ActiveConnection = MM_maincms_STRING
MM_editCmd.CommandText = "INSERT INTO t_pcode_searches (pcsearch_pc, pcsearch_outcome, pcsearch_stamp, pcsearch_ip) VALUES (?,?,?,?)"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 10, Request.Form("postcode")) '' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 202, 1, 10, "ok") '' adVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 135, 1, 50, Now()) '' date
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 202, 1, 50, Request.ServerVariables("REMOTE_ADDR")) '' adVarWChar
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close
End If
End If

Else '' we''ve come from the map page

''get url params
nptCode=UCase(Request.QueryString("id"))
nptDistrict=LCase(Request.QueryString("district"))
''set district to correct value
Select Case nptDistrict
Case "salisbury"
nptDistrict="Salisbury"
Case "swindon"
nptDistrict="Swindon"
Case "nwilts"
nptDistrict="North Wiltshire"
Case "wwilts"
nptDistrict="West Wiltshire"
Case "kennet"
nptDistrict="Kennet"
Case Else
nptDistrict=""
End Select

End If

''set variable to check we have everything we need (used later)
If (nptCode="" Or nptDistrict="")Then
novals=True
End If


Dim xmlDoc
Set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")
xmlDoc.async=false
xmlDoc.load(Server.MapPath("xml/nptdata.xml"))
xmlDoc.setProperty "SelectionLanguage", "XPath"

If xmlDoc.parseError.errorcode<>0 then
Response.Write(xmlDoc.parseError.errorcode)
Response.Write("</br>Error processing xml file")

End If


nodepath="/NPTInfo/District[@DistrictName=''"&nptDistrict&"'']/NPT[@NPTCode=''"&nptCode&"'']"
%>

推荐答案

嗯我们将永远不会只是分发代码 - 感觉就像我最近说的那样,以及其他人。无论如何,我能做的是:请参考 mysql / php 的一些教程。 ;但在此之前,您可能希望实际 grede=\"http://www.w3schools.com/PHP/default.asp\" target=\"_blank\">学习PHP


我希望你的项目一切顺利。


ps。当你展示了一些主动权并给我们展示你如何自己动手时,我们将很乐意提供更多帮助!


pss。在论坛中发布代码时 - 在这种情况下为ASP - 将其包装在[code]标签中。让它更容易阅读。
Well, as rule goes, will we never just hand out code - feels like I''m saying this alot recently, and others, too. Anyway, what I can do is: refer you to some tutorials on mysql/php; but before that you might want to actually learn PHP.

I hope all goes well in your project.

ps. When you''ve shown some initiative and given us a show of how you''v had a go at this yourself, we''ll be glad to help more!

pss. When posting code in the forum - ASP in this case - wrap it in [code] tags. Makes it alot easier to read.


对不起,我希望有人可以翻译它,然后我可以将它与我的尝试进行比较。这是我的尝试,你能看一下吗?


[HTML] mysql_select_db(
Sorry, i was hoping someone could translate it and then i could compare it to my attempt. here is my attempt, would you be able to take a look please?

[HTML]mysql_select_db(


database_wpolconn,
database_wpolconn,


这篇关于ASP到PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆