Current location: Hot Scripts Forums » Programming Languages » ASP » Expected end of statement


Expected end of statement

Reply
  #1 (permalink)  
Old 03-28-04, 06:46 PM
tbig's Avatar
tbig tbig is offline
Newbie Coder
 
Join Date: Jan 2004
Location: Massachusetts
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Expected end of statement

Hey guys,

I have a if/then statement with a link, and a variable from the DB called into it. The problem is, the variable from the DB won't show. Here's what I have:

<%
If rs("approved") = 0 then
Response.write "<a href='view.asp?approve="&id&"'>Approve</a>"

Else

Response.write "<font size='1' font color='red'>Approved</font>"
End if
%>

With the script above, it shows the link and all, just the ID is missing, therefore the script won't work. I come out with 'view.asp?approve='.

Any help?
__________________
Cheers!

TBig
Reply With Quote
  #2 (permalink)  
Old 03-28-04, 11:26 PM
af11kcc's Avatar
af11kcc af11kcc is offline
Newbie Coder
 
Join Date: Sep 2003
Location: MX
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Where are you getting ID from?
Reply With Quote
  #3 (permalink)  
Old 03-29-04, 12:06 PM
MadDog MadDog is offline
Code Master
 
Join Date: Aug 2003
Posts: 935
Thanks: 0
Thanked 0 Times in 0 Posts
Lets see the full code...
__________________
Drew Gauderman
ASP - MSSQL Coder / Buisness Owner / Coder for Hire!
MSN-ICQ-AIM-YIM in Profile

http://www.iportalx.net an easy ASP portal system.
Reply With Quote
  #4 (permalink)  
Old 03-29-04, 01:16 PM
tbig's Avatar
tbig tbig is offline
Newbie Coder
 
Join Date: Jan 2004
Location: Massachusetts
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
<!--#include file="../db/connection.asp" -->
<!--#include file="check.asp" -->

<%
'*** Deletes our record
if request.querystring("delete") <> "" then
id = request.querystring("delete")

rs.open "SELECT * FROM events WHERE id = "& id &"",conn,3,3
rs.delete
rs.update
response.redirect "view.asp"
rs.close
end if
%>

<%
'***Approves event
if request.querystring("approve") <> "" then
id = request.querystring("approve")

rs.open "SELECT * FROM events WHERE id="&id&"" ,conn,3,3
rs("approved") = 1
rs.update
response.redirect "view.asp"
rs.close
end if
%>

<%
'*** Selects our data
rs.open "SELECT * FROM events ORDER BY Event_Name ASC" ,conn
%>
<html>

<head>
<title>Miami Events: Events</title>
</head>

<link rel="stylesheet" type="text/css" href="../zma.css">
<body>

<div align="center">
<center>
<table border="2" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="75%" id="AutoNumber1" height="489">
<tr>
<td width="100%" height="59" bgcolor="#FFFFFF">
<!--#include file="../header.htm" --></td>
</tr>
<tr>
<td width="100%" height="461" bgcolor="#FFFFFF">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="65%" id="AutoNumber2" height="221">
<tr>
<td width="100%" height="221">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber3">
<tr>
<td width="100%">
<p align="center"><a title="Back to ADMIN" href="index.asp">Back
to ADMIN</a></p>
</td>
</tr>
</table>
<p>&nbsp;</p>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber4" height="31">
<tr>
<td width="54%" height="15">
<h3>Name:</h3>
</td>
<td width="13%" height="15">
<h3>Edit:</h3>
</td>
<td width="15%" height="15">
<h3>Approve:</h3>
</td>
<td width="36%" height="15">
<h3>Delete</h3>
</td>
</tr>
<% Do while not rs.EOF
If rs.eof then
response.write "There are no events in the database"
end if
%>
<tr>
<td width="54%" height="20">
<p align="center"><%=rs("event_name")%></p>
</td>
<td width="13%" height="20">
<p align="center"><a href="eventdetails.asp?id=<%=rs("id")%>">
<img border="0" src="../images/edit.jpg"></a></p>
</td>
<td width="15%" height="20" align="center">
<%
If rs("approved") = 0 then
Response.write "<a href='view.asp?approve="&id&"'>Approve</a>"

Else

Response.write "<font size='1' font color='red'>Approved</font>"
End if
%></td>
<p></p>
<td width="36%" height="20">
<p align="center"><a href="view.asp?delete=<%=rs("id")%>">
<img border="0" src="../images/x.jpg"></a></p>
</td>
</tr>
<%
rs.MoveNext
loop
%>
</table>
</td>
</tr>
</table>
</center>
</div>
</td>
</tr>
</table>
</center>
</div>

</body>

</html>
<%rs.close%>

-----------------------------------------------------------

It works fine if I don't have it in the rsponse.write "", but when it's in it, doesn't work
__________________
Cheers!

TBig
Reply With Quote
  #5 (permalink)  
Old 03-29-04, 11:08 PM
MadDog MadDog is offline
Code Master
 
Join Date: Aug 2003
Posts: 935
Thanks: 0
Thanked 0 Times in 0 Posts
The problem is that you are getting the ID after someone has submitted it. Remove all the "Request.QueryString("ID")" from the script and add it to the top and outside the IF statements.
__________________
Drew Gauderman
ASP - MSSQL Coder / Buisness Owner / Coder for Hire!
MSN-ICQ-AIM-YIM in Profile

http://www.iportalx.net an easy ASP portal system.
Reply With Quote
  #6 (permalink)  
Old 03-30-04, 02:47 PM
tbig's Avatar
tbig tbig is offline
Newbie Coder
 
Join Date: Jan 2004
Location: Massachusetts
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by MadDog
The problem is that you are getting the ID after someone has submitted it. Remove all the "Request.QueryString("ID")" from the script and add it to the top and outside the IF statements.
the ID comes from the database. It should write into the link there, then move on to the next record, until RS.EOF. Beasically it's just writing from the database
__________________
Cheers!

TBig
Reply With Quote
  #7 (permalink)  
Old 03-30-04, 02:51 PM
af11kcc's Avatar
af11kcc af11kcc is offline
Newbie Coder
 
Join Date: Sep 2003
Location: MX
Posts: 82
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by tbig
the ID comes from the database. It should write into the link there, then move on to the next record, until RS.EOF. Beasically it's just writing from the database
Did you try MadDog's suggestion?
Reply With Quote
  #8 (permalink)  
Old 03-30-04, 03:09 PM
tbig's Avatar
tbig tbig is offline
Newbie Coder
 
Join Date: Jan 2004
Location: Massachusetts
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by af11kcc
Did you try MadDog's suggestion?
Yeah

The function works fine when the operator is there. THe only problem is getting the ID to show afater approve in the link.
example:

approve=(id of event here)
__________________
Cheers!

TBig
Reply With Quote
  #9 (permalink)  
Old 03-30-04, 08:21 PM
MadDog MadDog is offline
Code Master
 
Join Date: Aug 2003
Posts: 935
Thanks: 0
Thanked 0 Times in 0 Posts
You need to add one of the two (depends on what you are trying to do):

id = Clng(rs("ID"))

or

id = Clng(Request.QueryString("ID"))

The problem is that you dont have the ID set to anything after a link has been approved.
__________________
Drew Gauderman
ASP - MSSQL Coder / Buisness Owner / Coder for Hire!
MSN-ICQ-AIM-YIM in Profile

http://www.iportalx.net an easy ASP portal system.
Reply With Quote
  #10 (permalink)  
Old 03-31-04, 01:44 PM
tbig's Avatar
tbig tbig is offline
Newbie Coder
 
Join Date: Jan 2004
Location: Massachusetts
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
I got it going. I took out the "response.write" and just did "then %> (HTML here) <%else%> and so on.

Thanks for the help
__________________
Cheers!

TBig
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error.. Expected Array? Demon Visual Basic 0 12-14-03 10:23 PM
UPDATE statement not working! aleksgurl Perl 5 11-06-03 12:40 PM
Malfunctioning switch statement and processing cstallins PHP 2 10-20-03 08:48 PM
If/else statement working...but not working mdhall PHP 13 10-16-03 08:47 AM
If then statement acting up! geneane ASP 1 09-30-03 04:32 PM


All times are GMT -5. The time now is 04:17 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.