Click to See Complete Forum and Search --> : php to asp
janice
02-20-2004, 11:38 AM
I posted this same question in the php forum but there doesn't appear to be anyone with the answer.
So, I am trying my luck here.
Our php person has just left and there are a couple of php files (short files) that we need to convert to asp.
I don't understand the php syntax enough to make sense of it let alone try to convert to asp.
So I was wondering if anyone here knows of a tool that can convert php to asp.
Even better, if anyone is proficient in both and is willing to assist me.
Thanks in advance.
buntine
02-20-2004, 12:02 PM
I dont know af any php to asp conversion tools. Have you tried a google.com search?
What sort of thing do these PHP pages achieve? Do they involve MySQL database connectivity?
janice
02-20-2004, 12:26 PM
php does pretty much the same things that asp or any other server side script does and that is create connection string to any database of choice, manipulate, print them out to the screen, etc.
Differences here are mostly syntax and structure.
It is really not a big file and I can convert some of the codes to asp but there is a part of it that is confusing.
buntine
02-20-2004, 02:12 PM
lol. I know what PHP is, i have been using it for years!
I meant, what exactly does the script do? Then we can tell you whether it will be simple or difficult to convert the source to valid ASP.
janice
02-20-2004, 03:35 PM
sorry for the misunderstanding.
All the code is doing is allow a user to perform a search based on his/her preference.
For instance, if you search for a street address and there is a hit, if you click on that hit, it zooms into a location on a map.
Can I just post the code here?
If you think you can be of help, your help would be truly appreciated.
Here goes:
<?php
include("db_functions.php");
$conn = new RDBMS_Conn ("cat","rd","rd","rd");
$cur = $conn->Parse("select name, xmin(the_geom), ymin(the_geom), xmax(the_geom), ymax(the_geom), str_number, ' ('||community||', '||zip_code||')' from roads.daccess where address_srch ## '".strtr(rtrim($situs),' ','&')."' order by name, str_number");
#$cur = $conn->Parse("select a.situs, b.min_x, b.min_y, b.max_x, b.max_y, b.pin from taxcama2002 a, parcel b where a.pin = b.pin and situs like upper('$situs%')");
$cur->Execute;
$cnt = 0;
echo "<table width=100%>";
while ( $cur->Fetch() ) {
$cnt = $cnt + 1;
$sit = $cur->GetColumn(5) . " " . $cur->GetColumn(0) . $cur->GetColumn(6);
$left = $cur->GetColumn(1) - 500;
$bottom = $cur->GetColumn(2) - 500;
$right = $cur->GetColumn(3) + 500;
$top = $cur->GetColumn(4) + 500;
$pin = $cur->GetColumn(5);
if ($left != -250) {
if ($cnt == 1){echo "<tr><br><br><Font size=3 color=#330099><B>Click below on address to display the map</font><BR><BR></tr>";}
echo "<tr><td><a href=\"#\" onClick=\"zoomToExtent('$left $bottom $right $top', '$pin')\"><font size=\"-1\">$sit</font></a></td></tr>";
}
else {
echo "<tr><td><font size=\"-1\">$sit (no coordinates)</font></td></tr>";
}
}
echo "</table>";
if ($cnt == 0) { echo "<BR><BR><Center><B>No results</center>";}
$cur->Close();
$conn->Close();
#echo "$left" + 500;
#echo"<BR>";
#echo "$bottom" + 500;
#echo"<BR>";
#echo "$right" - 500;
#echo"<BR>";
#echo "$top" - 500;
#echo "$pin";
?>
This bit below is the most confusing to me:
echo "<table width=100%>";
while ( $cur->Fetch() ) {
$cnt = $cnt + 1;
$sit = $cur->GetColumn(5) . " " . $cur->GetColumn(0) . $cur->GetColumn(6);
$left = $cur->GetColumn(1) - 500;
$bottom = $cur->GetColumn(2) - 500;
$right = $cur->GetColumn(3) + 500;
$top = $cur->GetColumn(4) + 500;
$pin = $cur->GetColumn(5);
if ($left != -250) {
if ($cnt == 1){echo "<tr><br><br><Font size=3 color=#330099><B>Click below on address to display the map</font><BR><BR></tr>";}
echo "<tr><td><a href=\"#\" onClick=\"zoomToExtent('$left $bottom $right $top', '$pin')\"><font size=\"-1\">$sit</font></a></td></tr>";
}
else {
echo "<tr><td><font size=\"-1\">$sit (no coordinates)</font></td></tr>";
}
}
echo "</table>";
buntine
02-20-2004, 10:51 PM
This is not achievable in ASP. Unless you purchase a third party component named aspJpeg.
janice
02-21-2004, 07:51 AM
I appreciate your honesty but I don't see how aspJpeg helps to convert php to asp.
buntine
02-21-2004, 08:08 AM
Converting PHP syntax to ASP syntax is achieveable
The problem is, ASP cannot zoom in on images without using the aspJpeg component.
janice
02-21-2004, 01:34 PM
Buntine,
Please ignore the zoomtoextent part.
I have a map object that works great. This onClick=\"zoomToExtent('$left $bottom $right $top', '$pin')
will be invoking a javascript function which will be zooming into that map.
Please don't worry about what this does:
onClick=\"zoomToExtent('$left $bottom $right $top', '$pin')
If you convert everything else and left this zoomtoextent part, trust me I am home free.
I can handle that part.
I just need the php converted to asp.
PLEASE, PLEASE, PLEASE help and be my hero.
janice
02-23-2004, 10:58 AM
Good people,
I have somehow managed to translate my php to asp.
There were 2 php pages.
The first one, the one I posted here works great now.
The second page, fairly simpler than the first one is not working.
This is the translated copy but somehow, it just does not display anything.
The page is blank.
When I view the source, this is what it looks like:
<html>
<head><title>Search</title>
<script language="javascript" src="toolbar.js"></script>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body onLoad='window.focus()'>
<div align="center"></div>
<body>
<html>
and below is the translated code.
Can someone tell me what is wrong?
<%@language=vbscript%>
<html>
<head><title>Search</title>
<script language="javascript" src="toolbar.js"></script>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body onLoad='window.focus()'>
<%
dim atype
Response.Write "<div align=""center"">"
select case atype
case "owner":
Response.Write "<font size=""-1"">Enter name (e.g., smith john)</font><br>"
Response.Write "<form name=""owner_search"" method=""post"">"
Response.Write "<input type=""text"" name=""owner"" size=""20"">"
Response.Write "<input type=""submit"" name=""action"" value=""search"">"
Response.Write "<input type=""hidden"" name=""actionh"" value=""search"">"
Response.Write "</form>"
case "pin":
Response.Write "<font size=""-1"">Enter parcel PIN:</font><br>"
Response.Write "<form name=""owner_search"" method=""post"">"
Response.Write "<input type=""text"" name=""pin"" size=""20"">"
Response.Write "<input type=""submit"" name=""action"" value=""search"">"
Response.Write "<input type=""hidden"" name=""actionh"" value=""search"">"
Response.Write "</form>"
case "address":
Response.Write "<font size=""-1"">Enter the address</font><br>"
Response.Write "<form name=""situs_search"" method=""post"">"
Response.Write "<input type=""text"" name=""situs"" size=""20"">"
Response.Write "<input type=""submit"" name=""action"" value=""Search"">"
Response.Write "<input type=""hidden"" name=""actionh"" value=""search"">"
Response.Write "</form>"
Response.Write "<i><Font size=""2"" color=#660066><B>Do not abbreviate any word in street name <br>"
Response.Write " If you have problems try just a part of the street name<br>"
Response.Write " ex. ""141 Pryor"" -- finds 141 PRYOR SRTEET SW, <br>"
Response.Write " ""5165 WELCOME ROAD"" -- finds 5165 WELCOME ALL ROAD</font></i>"
case "street":
Response.Write "<font size=""-1"">Enter street name</font><br>"
Response.Write "<form name=""situs_search"" method=""post""> "
Response.Write "<input type=""text"" name=""street"" size=""20"">"
Response.Write "<input type=""submit"" name=""action"" value=""search"">"
Response.Write "<input type=""hidden"" name=""actionh"" value=""search"">"
Response.Write "</form>"
case "landlot":
response.write("<form name=""landlot_search"" method=""post"">" &_
"Enter tax district <select name=""dist"" size=""1"">" &_
"<option value=""11"">1-1</option>" &_
"<option value=""12"">1-2</option>" &_
"<option value=""21"">2-1</option>" &_
"<option value=""22"">2-2</option>" &_
"<option value=""06"">06</option>" &_
"<option value=""07"">07</option>" &_
"<option value=""08"">08</option>" &_
"<option value=""09C"">09C</option>" &_
"<option value=""09C"">09F</option>" &_
"<option value=""13"">13</option>" &_
"<option value=""14"">14</option>" &_
"<option value=""14F"">14F</option>" &_
"<option value=""15"">15</option>" &_
"<option value=""17"">17</option>" &_
"<option value=""18"">18</option>" &_
"</select>" &_
" </select>" &_
"and land lot <input type=""text"" name=""landlot"" size=""4"">" &_
"<input type=""submit"" name=""action"" value=""search"">" &_
"<input type=""hidden"" name=""actionh"" value=""search"">" &_
"</form>")
end select
response.write "</div>"
IF actionh = "search" Then
Select Case atype
Case "owner":
%><!--#include file="owner.asp"--><%
Case "pin":
%><!--#include file="pin.asp"--><%
Case "address":
%><!--#include file="situs_search.asp"--><%
Case "street":
%><!--#include file="street.asp"--><%
Case "address":
%><!--#include file="landlot.asp"--><%
case else
response.write ("Nothing selected")
End Select
End If
%>
<body>
<html>
buntine
02-23-2004, 11:16 AM
case "pin":
'code...
ASP does not require you to use a colon in a select-case statement. That is only mandatory in languages which follow C-style syntax rules.
Use this instead:
case "pin"
'code...
Regards.
janice
02-23-2004, 11:32 AM
that is not the problem.
buntine
02-23-2004, 12:08 PM
Ok, but it is a problem.
Your problem is that you have not defined 'aType'. All you have done is declared it..
At the moment, aType equals null.
Regards.
janice
02-23-2004, 01:02 PM
it is defined in this javascript function:
function openSearch() {
var search_type = document.buttonForm.search.options[document.buttonForm.search.selectedIndex].value;
window.open("search.asp?atype="+search_type,"searchWin","width=500,height=400,scrollbars,resizable,status");
document.buttonForm.search.selectedIndex = 0;
buntine
02-23-2004, 10:07 PM
Yes, javascript cannot communicate with ASP. Active Server Pages is a server-side language, it has no way of using variables which have been defined in a different programming language..
The problem is still that fact that aType is empty. You will have to define the variable in ASP or determine some method of sending the string to the server.
Regards.
janice
02-23-2004, 10:39 PM
Good thing I came here to find a solution to the problem I have.
Otherwise, I could argue with you forever that you are wrong in thinking that Javascript and asp cannot communicate.
I came here NOT because I didn't know asp or javascript but I didn't know php.
Asp and Javascript communicate all the time.
buntine
02-24-2004, 02:37 AM
Janice, im sorry for offending you. But you are wrong, what your are saying is completely illogical.
Javascript cannot directly communicate with ASP.. Javascript runs on the client and ASP runs on the server. That fact alone explicitly forbids ASP from accessing memory locations which have javascript variables within them.. It just isnt possible to use your 'aType' variable in an ASP script.
When your ASP script executes, it cannot grab data from a script on the client..
Just to make my point clear, javascript executes from the browser and stores variables in the clients memory stack. ASP executes from the server and stores its program variables on the servers memory stack, hence the reason you cant use 'msgBox' methods with ASP.
Regards,
Andrew Buntine.