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!

QueryString Syntax error 1

Status
Not open for further replies.

csiwa28

Programmer
Apr 12, 2001
177
I'm getting this syntax error for a query string that I can't figure out why. It gives me an error at the question mark. What the asp page does is read from a database and then write the names on the page as links, and each link is supposed to pass a value. What am I doing wrong?

Response.Write &quot;<a href = &quot;/products/company.asp?<%=&quot;Name=&quot; & objRec(&quot;Name&quot;)%>&quot;>&quot; & objRec(&quot;Name&quot;) & &quot;</a>&quot; & &quot;<BR>&quot;
 
Here's how I did it.


<%

Option Explicit


Dim cnnDB, strQuery, rsInfo

'Create an instance of the Connection object.
Set cnnDB = Server.CreateObject(&quot;ADODB.Connection&quot;)

'And open it.
cnnDB.Open &quot;Test&quot; 'Test is my ODBC DSN

'Build our SQL query string.
strQuery = &quot;SELECT File,Namez,FileSize,LAstMod FROM tblDocumentIndex Where File Not Like 'c:\%' ORDER BY File&quot;

'Execute the query and return a recordset.
Set rsInfo = cnnDB.Execute(strQuery)

%>

<HTML>
<HEAD>
</HEAD>
<BODY>
<BODY LINK=&quot;#0000ff&quot; VLINK=&quot;#800080&quot; BACKGROUND=&quot;Image3.jpg&quot;>
<CENTER><H2>
Microsoft Access Files at Tempo</H2>
<CENTER><p>
This report was created using IIS 4.0, Microsoft Access and Active Server Pages (ASP)</p>
<CENTER><p>
This report is &quot;Live&quot;</p>
<P><HR></P>
<BR>
<TABLE>
<TR>
<TH align=&quot;left&quot;>

File Name and Path
</TH>
<td width=&quot;15&quot;><br></td>
<TH align=&quot;left&quot;>
File Name
</TH>
<td width=&quot;15&quot;><br></td>
<TH align=&quot;left&quot;>
Size
</TH>
</TH>
<td width=&quot;15&quot;><br></td>
<TH align=&quot;left&quot;>
Date Last Modified
</TH>

</TR>

<%
'Iterate through the recordset, pull
'out the required data, and insert it
'into an HTML table.
Do While Not rsInfo.EOF
%>



<TR>
<TD><A HREF=<% =rsInfo(&quot;File&quot;) %>><% =rsInfo(&quot;File&quot;) %></A></TD>
<td width=&quot;15&quot;><br></td>
<TD><% =rsInfo(&quot;Namez&quot;) %></TD>
<td width=&quot;15&quot;><br></td>
<TD><% =formatnumber(rsInfo(&quot;FileSize&quot;)/1000000,2) %></TD>
<td width=&quot;15&quot;><br></td>
<TD><% =formatdatetime(rsInfo(&quot;LastMod&quot;),vbShortDate) %></TD>
<td width=&quot;15&quot;><br></td>
</TR>

<%
'Move to the next record in the
'recordset
rsInfo.MoveNext

Loop

'Close the recordset.
rsInfo.Close

'And close the database connection.
cnnDB.Close
%>

</TABLE>
</CENTER>

</BODY>
</HTML>
 
U have to put something like this
/products/company.asp?myvariable=myvalue?...

Response.Write &quot;<a href = &quot;/products/company.asp?Name=&quot;<%= Server.URLEncode(objRec(&quot;Name&quot;))%>&quot;>&quot; & objRec(&quot;Name&quot;) & &quot;</a>&quot; & &quot;<BR>&quot;

and use then Request.QuerryString(&quot;Name&quot;) ________

George
 
sorry this should look like this...

Response.Write &quot;<a href = &quot;/products/company.asp?Name=&quot;& Server.URLEncode(objRec(&quot;Name&quot;))&&quot;>&quot; & objRec(&quot;Name&quot;) & &quot;</a>&quot; & &quot;<BR>&quot;
________

George
 
Hello,
I'm sure you get the error
Invalid character
/bbb.asp, line 8, column 48
because you didn't pay attention for corresponding quotes.
Also, you cannot nest <% %>

Try:
lnk = &quot;<a href=&quot;&quot;&quot; & &quot;/products/company.asp?&quot; & &quot;Name=&quot; & Server.URLEncode(objRec(&quot;Name&quot;)) & &quot;&quot;&quot;>&quot; & objRec(&quot;Name&quot;) & &quot;</a>&quot; & &quot;<BR>&quot;
Response.Write lnk

&quot;&quot; - two times quote escapes quote and you can use it.
I put URLEncode function because in my case I had intervals(spaces) in the Name field.

D.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top