 |
| Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 6th, 2006, 11:47 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
The caution box in IE means that there is a javascript syntax error. Umm. Is the <script language="javascript"> between your <head></head> tags?
And yes, EVERYONE likes quickies. }=]
--Stole this from a moderator
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
|
|

October 6th, 2006, 11:57 AM
|
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
No, does it need to be? I wouldn't think so, but lemme try it.........
***
No, i tried puttin' it in there and that's definitely not working. I might need to give this one a rest for an hour or something and do something else for a little while-- I think I'll print it all out and just sit down and read the whole thing again, try to see what the heck is going wrong in there.
Toni Burgess
[email protected]
|
|

October 6th, 2006, 12:22 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
Something I noticed you are doing this:
sFileSplit = split(o.FileNameOf("ecpFilename"), "\")
sFile = sFileSplit(Ubound(sFileSplit))
You should do this:
if instr(o.FileNameOf("ecpFilename"), "\") then
sFileSplit = split(o.FileNameOf("ecpFilename"), "\")
sFile = sFileSplit(Ubound(sFileSplit))
else
//user didnt submit a good path
end if
The subscript error is occuring because when you try to split, there is no character to split on =
My first page might look something like this:
<%@ LANGUAGE="VBSCRIPT"%>
<% Option Explicit %>
<%
if Session("UserID") = "" then
Response.Redirect("index1.asp")
end if
if LCase(Session("UserType")) <> "originator" then
Response.Redirect("noPostNew1.asp")
end if
%>
<html>
<head>
<title>something</title>
<script language="javascript">
<!--
function checkData(){
if (document.myForm.ecpFilename.value.length == 0 ) {
alert("missing file");
return false;
}
else {
alert("Sending data...");
myForm.submit();
return true;
}
}
-->
</script>
</head>
<body>
<form method="post" action="postNew1.asp" enctype="multipart/form-data" name="myForm">
<P><INPUT type="file" name="ecpFilename"></P>
<P><INPUT type="button" onclick="checkData()" value="Button"></P>
</form>
</body>
</html>
</file>
my second page might look like:
<%@ LANGUAGE="VBSCRIPT"%>
<% Option Explicit %>
<%
set o = new clsUpload
if o.Exists("submitButton") then
if instr(o.FileNameOf("ecpFilename"), "\") then
sFileSplit = split(o.FileNameOf("ecpFilename"), "\")
sFile = sFileSplit(Ubound(sFileSplit))
'Upload filename
o.FileInputName = "ecpFilename"
o.FileFullPath = Server.MapPath(".") & "\ecpFiles\" & sFile
o.save
'If not error redirect to complete message
if o.Error = "" then
Dim pSQLStatement, pConnection
Dim pRS, objMail
Dim pEcpNumber, pEcpTitle, pEcpFilename, pEcpOriginator, pEcpDateDistributed, pEcpDateDue
pEcpNumber = o.ValueOf("ecpNumber")
pEcpTitle = o.ValueOf("ecpTitle")
pEcpFilename = sFile
pEcpOriginator = o.ValueOf("ecpOriginator")
pEcpOriginator = Session("UserFullName")
pEcpDateDistributed = CStr(date())
pEcpDateDue = CStr(o.ValueOf("ecpDateDue"))
pConnection = "Provider=SQLOLEDB.1;UID=sa;PWD=;Initial Catalog=ecpDatabase2SQL;Data Source=localhost"
Set pRS = server.CreateObject("ADODB.RecordSet")
pRS.open "INSERT INTO ecpForms (ecpNumber, ecpTitle, ecpFilename, ecpOriginator, ecpDateDistributed, ecpDateDue) VALUES ('" & pEcpNumber & "', '" & pEcpTitle & "', '" & pEcpFilename & "', '" & pEcpOriginator & "', '" & pEcpDateDistributed & "', '" & pEcpDateDue & "') ", pConnection
else
%>
<script language="JavaScript">
alert('You provided an invalid file name!');
self.location.href='PostNew1.asp';
</script>
<%
end if
%>
hth
--Stole this from a moderator
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
|
|

October 6th, 2006, 01:32 PM
|
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I'm trying to implement it, but seems like no matter what I do to the dag on thang it still gives me the same error in the same spot.
You have your example set up in two pages, where as I have all that on one page. But even with adding it the way you have it above (except all in just one page) it's still giving me an error, and I have yet to receive an alert box.
Toni Burgess
[email protected]
|
|

October 6th, 2006, 01:45 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
O.o That positively doesnt make any sense. How do you determine when the form handler portion of your code will execute?
--Stole this from a moderator
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
|
|

October 6th, 2006, 02:11 PM
|
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I give up (for now).
It must not be meant for me to figure it out right now. I've changed everything back to how it was working before(which I'm surprised I even remembered). It does what they asked of me, so that's fine for me right now. Thanks :)
I'll figure the extras out later, right now my mind is too cluttered with frustration; if I have anymore failed attempts I may just start crying (remember: laugh about everything, cry about nothing). ;) It'll be okay tho. Most times when you're over frustrated you don't see nor think clearly. So, once I have cleared my mind of it for a little while, I may be able to see what I'm doing wrong when I go back to it. (Cause right now I'm thinking "Down with Java! Down with ASP!" lol
Toni Burgess
[email protected]
|
|

October 6th, 2006, 02:14 PM
|
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Oh but speaking of which, do you know any good websites for program ideas? Ideas for creating programs? I know that sounds kind of silly, but now I have to think of something to create! (I think this is the hardest part--especially when you have no specific needs right now, i.e. no store to manage, records to keep track of, etc).
Toni Burgess
[email protected]
|
|

October 6th, 2006, 02:16 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
LoL. Its normal to get frustrated, it happens to everyone! (I for example just about threw my mouse across my office because I couldn't get this stupid Regular Expression to match a string correctly...all is now well and my mouse remains in one piece)
As far as your problem goes, I am not sure it is something obscure. If i had the code on my machine and could look through it I might figure it out but se la vi. =P
--Stole this from a moderator
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
|
|

October 6th, 2006, 02:47 PM
|
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
not very good at Spanish, if that's Spanish (looked like it lol), but hey I did pass it all four times with a 98 or higher! (two classes in high school, two in college).... but anyway I'm gettin' off subject lol.
I've taken a breather! I thought of program ideas to no avail! I am ready to tackle this thing again lol. No tears nor frustration, I am fully boosted with confidence this time!
Oh and by the way, the code is on it's way lol
;)
Toni Burgess
[email protected]
|
|

October 7th, 2006, 12:09 PM
|
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ok I found the problem for my error page. I was looking at the wrong code in my postNew1.asp here's what I did:
<%
set o = new clsUpload
if o.Exists("submitButton") then
'get client file name without path
dim strMessage
if o.FileNameOf("ecpFilename") = "" then
response.redirect("postNew1.asp")
else
sFileSplit = split(o.FileNameOf("ecpFilename"), "\")
sFile = sFileSplit(Ubound(sFileSplit))
'Upload filename
o.FileInputName = "ecpFilename"
o.FileFullPath = Server.MapPath(".") & "\ecpFiles\" & sFile
o.save
end if
'this little if then else statement stops the page from going to the error page when the user does not enter a filename. I don't know how I could have missed this, it makes perfect sense that this is why i kept getting an error page. But anyWHO, I got it going back to the postNew1.asp page but I still don't have the alert working. However, I figured I needed to call it somewhere here, right before the response.redirect ?
Toni Burgess
[email protected]
|
|
 |