...

View Full Version : whats this in asp?



mivec
08-18-2005, 12:30 PM
hi all,
can someone tell me whats the keyword/reserved word in asp for these two php reserved words:



$_GET["something"];
$_POST["something"];


really need to know....anyone???? urgent here....

thanks

Spudhead
08-18-2005, 01:19 PM
My PHP isn't much but I think what you want is:

request.querystring("something")
request.form("something")

mivec
08-18-2005, 03:29 PM
My PHP isn't much but I think what you want is:

request.querystring("something")
request.form("something")

hmm....ok...i think that will work....by the way, another translation from php to asp required:



1)!ISSET(something) in asp?
2)also whats the switch-case syntax for asp?


sorry for the noobish questions....but i rally am a noob IN asp......sigh....

cheers

nikkiH
08-18-2005, 03:36 PM
1. IsNull (varname)

2.


Select Case varname
Case 1
' do something
Case 3
' do something else
Case Else
' default
End Select

Cyberlord
08-18-2005, 03:54 PM
1. IsEmpty(var) ???

oracleguy
08-18-2005, 07:04 PM
If var = "" then
its empty!
end if

Assuming what I understand correctly IsEmpty to actually do.

Cyberlord
08-18-2005, 07:47 PM
Yes oracle, its the same.

@nikkiH:
You will never get a NULL for a request.form or request.querystring.
NULL is different from an empty string.

nikkiH
08-18-2005, 09:10 PM
He asked for the equivalent to isset (which checks for the existence of a variable: php does not make you declare variables), not checking a value for empty string (String.Empty in .net).

Since VBscript always inits variables to null (IIRC, since all are Variant type), you'd test for null. And I ALWAYS use option explicit, which forces variable declaration.

http://us2.php.net/isset
http://www.w3schools.com/vbscript/func_isnull.asp

If it is a string, yeah, you could just do the comparison as was suggested.
if var = "" then
' do something
end if

mivec
08-19-2005, 08:53 PM
thanks guys...will test it out in a bit..anyway...there is one more that i need to know from php to asp:



date("YmdHis");


cheers

Cyberlord
08-19-2005, 09:28 PM
Hello,


"FormatDateTime" is right for you.

Look in your documents for detailed datetime-formats with this command.


cheers

mivec
08-20-2005, 07:02 AM
Hello,


"FormatDateTime" is right for you.

Look in your documents for detailed datetime-formats with this command.


cheers

err.....thanks cyberlord but could i have an exmaple how to declare it??like in php its :



$var = date("YmdHis");


so maybe need some help here on how to exactly declare it....noob in asp..really sorry... :(

mivec
08-20-2005, 06:37 PM
another one....really sorry.....in php it is :



$var->affectedRows()


so what is it like in asp? really for asking these questions.....hopefully u can be patient with me...thanking u all in advance.

cheers

ghell
08-21-2005, 12:00 AM
checking if a variable exists should technically be IsEmpty() but IsNull() returns the same as if it doesnt exist it has a null value (the difference is in option explicit) and = "" is just cos as it is variant type when it has null value it comes out as "" or 0

as for the date function there is no intrinsic asp function to format the date, you have to make your own (i made a big function a while ago to mimic phps as the only useful functions i could find in php not asp were mail() and date())

asp has Now() Time() and Date() to get the current datetime time and date respectively, FormatDateTime(Date(), vbLongDate) returns a string for example 20 August 2005. there are functions such as Year() Hour() etc which will return one element of the date. also check out the CDate() function to convert strings etc into variant of subtype date for this sort of function.. adding 1 to a date is 1 day)

please look at the links in my signature and http://www.w3schools.com/asp for further help. (in particular look at the link in the [D] in my sig, this is for vbscript so is slightly diff from asp but its pretty much the same, all the same functions etc but u shud use some serverfunctions eg Server.CreateObject() instead of just CreateObject() and ofc things like MsgBox() and WSH are not available in asp (i think wsh isnt anyway)

i cant remember what $var->affectedRows() does so i cant really tell you what it is in asp :rolleyes:

mivec
08-21-2005, 06:23 AM
checking if a variable exists should technically be IsEmpty() but IsNull() returns the same as if it doesnt exist it has a null value (the difference is in option explicit) and = "" is just cos as it is variant type when it has null value it comes out as "" or 0

as for the date function there is no intrinsic asp function to format the date, you have to make your own (i made a big function a while ago to mimic phps as the only useful functions i could find in php not asp were mail() and date())

asp has Now() Time() and Date() to get the current datetime time and date respectively, FormatDateTime(Date(), vbLongDate) returns a string for example 20 August 2005. there are functions such as Year() Hour() etc which will return one element of the date. also check out the CDate() function to convert strings etc into variant of subtype date for this sort of function.. adding 1 to a date is 1 day)

please look at the links in my signature and http://www.w3schools.com/asp for further help. (in particular look at the link in the [D] in my sig, this is for vbscript so is slightly diff from asp but its pretty much the same, all the same functions etc but u shud use some serverfunctions eg Server.CreateObject() instead of just CreateObject() and ofc things like MsgBox() and WSH are not available in asp (i think wsh isnt anyway)

i cant remember what $var->affectedRows() does so i cant really tell you what it is in asp :rolleyes:

the $var->affectedRows() will return an integer value. what it does is that if ur statement does any changes to any of the records that u have selected, it will return an integer value. how it's used is like this:



if ($var->affectedRows() > 0)
echo ("stuff edited");
else
echo("stuff not edited");


so as u can see, it will return a value saying that it is true and if not it will go to not true......dunno if i am explaining it the right way...:p.
so how can i do it in asp?

cheers

ghell
08-21-2005, 12:58 PM
id just use the optional second argument in objConn.Execute(strSQL, intAffectedRows)

(ive never actually used it but thats what the documentation says, i assume it just puts the number of affected rows into that variable)

mivec
08-22-2005, 09:04 PM
another php to asp question:



$rs = mysql_query($sql);
$nRows = mysql_num_rows($rs);


is there an asp key word for those two?(mysql_query and mysql_num_rows)

thanks a mill

ghell
08-22-2005, 09:15 PM
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "..."

Set rsBlah = objConn.Execute("SELECT * FROM sometable", intRows)
If NOT rsBlah.EOF Then
arrBlah = rsBlah.GetRows()
End If
Set rsBlah = Nothing

objConn.Close
Set objConn = Nothing

Response.Write intRows & " Rows Returned<hr><pre>"

If IsArray(rsBlah) Then
For iRecords = LBound(arrBlah, 2) To UBound(arrBlah, 2)
For iFields = LBound(arrBlah, 1) To UBound(arrBlah, 1)
Response.Write arrBlah(iFields, iRecords) & vbTab
Next
Response.Write vbNewLine
Next
Else
Response.Write "No Records Found"
End If
Response.Write "</pre>"this uses getrows which is a pretty fast way of getting the data out as you can close hte objects quickly. if intRows doesnt work (i havnt tried, never needed anything that used it) then the number of rows is also UBound(arrBlah, 2)

mivec
08-23-2005, 08:29 AM
thanks ghell.....but here's another one:

PHP:


$sql .= ' LIMIT ' . $startPos . ', ' . $pageSize;


whats the 'LIMIT' thing there in asp? thanks and cheers

neocool00
08-23-2005, 03:54 PM
One minor change for ghell's code. This "If IsArray(rsBlah) Then" should be this "If IsArray(arrBlah) Then".

mivec,
There is another thread (http://www.codingforums.com/showthread.php?t=66493) about pagination, check it out for help.

mivec
08-24-2005, 08:44 PM
hi all,
yet another php command:

in php:


nl2br(something);


so whats it in asp????

thanks again guys....

Cyberlord
08-24-2005, 08:49 PM
Because we are all ASP-Coder, please write the function of the PHP-Code here, so we can better help you.

cheers

Grant Palin
08-24-2005, 09:04 PM
nl2br is a built-in PHP function. As I recall, it (supposedly) converts newlines to BR tags. But what it actually does is insert a BR tag, but keeps the newline, making the function name a bit misleading.

I don't think there is a direct ASP equivalent, but you could probably write a quick function to do the job. Here's my go at it (note: written quickly, may or may not work).



Function nl2br(input)
nl2br = Replace(input, vbCrLf, vbCrLf + "<br />")
End Function



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum