Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting variables into database

Status
Not open for further replies.

sq000

Technical User
Jul 15, 2001
3
GB
hi im trying to get variables into a database,
can anyone see anything obviousley wrong with this code?
i would be very greatful for any help

i think the problem is in the "insert" lines thanks again

<%@LANGUAGE=&quot;JAVASCRIPT&quot;%>
<!--#include file=&quot;Connections/lostat.asp&quot; -->
<%

var Command1 = Server.CreateObject(&quot;ADODB.Command&quot;);
Command1.ActiveConnection = MM_lostat_STRING;
Command1.CommandText = &quot;INSERT INTO tblStats (Recorded, RemoteAddress, HttpReferer, HttpUserAgent, WebPage) VALUES ('&quot; & Request(&quot;date&quot;) & &quot;', '&quot; & Request(&quot;REMOTE_ADDR&quot;) & &quot;', '&quot; & Request(&quot;HTTP_REFERER&quot;) & &quot;', '&quot; & Request(&quot;HTTP_USER_AGENT&quot;) & &quot;', '&quot; & Request(&quot;URL&quot;) & &quot;') &quot;;
Command1.CommandType = 1;
Command1.CommandTimeout = 0;
Command1.Prepared = true;
Command1.Execute();

%>
<SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>
function DoDateTime(str, nNamedFormat, nLCID)
dim strRet
dim nOldLCID

strRet = str
If (nLCID > -1) Then
oldLCID = Session.LCID
End If

On Error Resume Next

If (nLCID > -1) Then
Session.LCID = nLCID
End If

If ((nLCID < 0) Or (Session.LCID = nLCID)) Then
strRet = FormatDateTime(str, nNamedFormat)
End If

If (nLCID > -1) Then
Session.LCID = oldLCID
End If

DoDateTime = strRet
End Function
</SCRIPT>
<html>
<head>
<title>test</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
</head>
<body bgcolor=&quot;#FFFFFF&quot; text=&quot;#000000&quot;>
<p>
<input type=&quot;hidden&quot; name=&quot;12&quot; value=&quot;<%= DoDateTime( Request(&quot;date&quot;) , 2, 2057) %>&quot;>
<input type=&quot;hidden&quot; name=&quot;13&quot; value=&quot;<%= Request(&quot;REMOTE_ADDR&quot;) %>&quot;>
<input type=&quot;hidden&quot; name=&quot;14&quot; value=&quot;<%= Request(&quot;HTTP_REFERER&quot;) %>&quot;>
<input type=&quot;hidden&quot; name=&quot;15&quot; value=&quot;<%= Request(&quot;HTTP_USER_AGENT&quot;) %>&quot;>
<input type=&quot;hidden&quot; name=&quot;16&quot; value=&quot;<%= Request(&quot;URL&quot;) %>&quot;>
test</p>
<p>&nbsp;</p>
</body>
</html>
 
The problem is that u trying to add a string like VBScript not JavaScript
myStr=&quot;somstring&quot;&otherString
this work only in VB but in java u have to put + not &
& in vb add two strings but in java means AND

This is Java
<%@LANGUAGE=&quot;JAVASCRIPT&quot;%>
<!--#include file=&quot;Connections/lostat.asp&quot; -->
<%

var Command1 = Server.CreateObject(&quot;ADODB.Command&quot;);
Command1.ActiveConnection = MM_lostat_STRING;
Command1.CommandText = &quot;INSERT INTO tblStats (Recorded, RemoteAddress, HttpReferer, HttpUserAgent, WebPage) VALUES ('&quot; + Request(&quot;date&quot;) + &quot;', '&quot; + Request(&quot;REMOTE_ADDR&quot;) + &quot;', '&quot; + Request(&quot;HTTP_REFERER&quot;) + &quot;', '&quot; + Request(&quot;HTTP_USER_AGENT&quot;) + &quot;', '&quot; + Request(&quot;URL&quot;) + &quot;') &quot;;
Command1.CommandType = 1;
Command1.CommandTimeout = 0;
Command1.Prepared = true;
Command1.Execute();
%>

This is in VB
<%@LANGUAGE=&quot;VBSCRIPT&quot;%>
<!--#include file=&quot;Connections/lostat.asp&quot; -->
<%

Command1 = Server.CreateObject(&quot;ADODB.Command&quot;)
Command1.ActiveConnection = MM_lostat_STRING
Command1.CommandText = &quot;INSERT INTO tblStats (Recorded, RemoteAddress, HttpReferer, HttpUserAgent, WebPage) VALUES ('&quot; & Request(&quot;date&quot;) & &quot;', '&quot; & Request(&quot;REMOTE_ADDR&quot;) & &quot;', '&quot; & Request(&quot;HTTP_REFERER&quot;) & &quot;', '&quot; & Request(&quot;HTTP_USER_AGENT&quot;) & &quot;', '&quot; & Request(&quot;URL&quot;) & &quot;') &quot;
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top