Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- php code in asp
June 23, 2010, 12:14 pm
rate this thread
I am new to asp, but have some experience in php.
I need to mirror this php code in asp.
SQL = "select * from journeys where id in $acceptedvals";
This is the working code (on an asp site i inherited that I am tryng
to alter because I dont want to display all the alternatives, I just
want to select the alternatives that are listed in a hard coded
Set objRS = Server.CreateObject("ADODB.Recordset")
Set objConn = Server.CreateObject("ADODB.Connection")
SQL = "select * from journeys order by startdate, name"
objRS.Open SQL, objConn, 3,3
do while NOT objRS.EOF
If Request.QueryString("trip") = objRs("id") Then %>
selected="selected"<% End If %>>
My poor attempt just led to an unreadable webpage
I added this at start
And changed the Sql" row to
SQL="select * from journeys where objRs("id") in &acceptedvals order
by startdate, name"
But this did not work!
Any help greatly appreciated
In php I can use ' and " when I have multiple uses, but in asp the '
seems to comment out what I want to write
Sorry for asking here, google is not showing me an asp group so I am
lost...... if u cant answer can u point me to an asp group,
June 23, 2010, 12:23 pm
Re: php code in asp
El 23/06/2010 14:14, GarryJones escribió/wrote:
Given that you actually mean this:
$acceptedvals = '(24,29,30)';
SQL="select * from journeys where " & objRs("id") & " in " &
acceptedvals & " order by startdate, name"
ASP is not a language: it's a technology that can be written in several
languages. Your code is written in VBScript. Differences between
VBSCript and PHP include:
- Concatenation operator is & rather than . (dot)
- There is no variable parsing in strings
- Code cannot span across several lines
- ... unless you are concatenating strings:
SQL = foo & bar
SQL = foo &_
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
Re: php code in asp
Irregardless of whether you found another group or not, this isn't the
right place for asp questions. I don't know of any asp groups, but then
I've never looked for one, either.
You need to keep looking. But since asp is an access method and not a
language, you might try the language (visual basic in this case).
Remove the "x" from my email address
JDS Computer Training Corp.
Re: php code in asp
writing in news:86a11ae7-641c-4acd-84df-e28fe7f1d202
Cross posted to microsoft.public.inetserver.asp.general, followups set.
First of all it is not a good idea to use the wildcard * in a sql
statement. Always explicitly name the fields you want. Why? Because
the table could change over time, new fields added, removed, etc. You
are also making the query engine work harder.
The only time you would want to use * is if you are working with the
table directly, say in Heidi, and you need to know the names of the
fields because you are working on a query before deploying it in your
sql = "SELECT id, name, startdate, enddate " &_
" FROM journeys " &_
" ORDER BY startdate, name"
You would also do better using the getrows() method. That way you are
not keeping the database open. Best thing to do, get in, get out.
objarr = objrs.getrows()
set objrs = nothing
for i = 0 to ubound(objarr,2)
id = objarr(i,0)
name = objarr(i,1)
startdate = objarr(i,2)
enddate = objarr(i,3)
<option value="<%=id%>" <% if request.querystring("trip") = id then %>
selected="selected"<% end if%> ><%=name%> <%=startdate%> -> <%=enddate%>
<% next %>
Should be acceptedvals = "24, 29, 30"
(Goodness! It's so hard to refrain from ending lines with a semi-
sql = "SELECT id, name, startdate, enddate FROM journeys " &_
" WHERE id IN (" & acceptedvals & ") ORDER BY startdate, name"
That's correct, and it only comments out one line at a time. There is
no multi-line comment as there is in PHP.
I have cross posted to microsoft.public.inetserver.asp.general, and set
followups as well.
Adrienne Boswell at Home
Arbpen Web Site Design Services
Please respond to the group so others can share
- » [embedded] Using php-cgi to handle www + CLI scripts?
- — Next thread in » PHP Scripting Forum