The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> ASP Programming
|
Help w/ ASP Mid Function Please
Discuss Help w/ ASP Mid Function Please in the ASP Programming forum on Dev Shed. Help w/ ASP Mid Function Please ASP Programming forum discussing Active Server Pages coding techniques and problem solving methods. Use VBScript or Jscript to make dynamic web applications.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 30th, 2012, 09:07 AM
|
|
Contributing User
|
|
Join Date: Jan 2004
Location: Budapest
|
|
|
Help w/ ASP Mid Function Please
I want to have a form such that one field would be a URL for a YouTube video, suuch as these examples:
http://www.youtube.com/watch?v=gGqj6jKVWI0&feature=plcp
http://www.youtube.com/watch?v=gGqj6jKVWI0
What I am ultimately after is the code for the video, in this case gGqj6jKVWI0
I noticed in some situations the YouTube video ends w/ what I am after and other times it adds characters after it.
I thought I had this working at one time but I keep getting an error. Here is the code I had been using that I thought worked.
Code:
var1 = instr(Request("code"),"http://www.youtube.com/v/")
var2 = instr(Request("code"),"&")
var3 = (var2 - var1) - 25
mySQL= "INSERT INTO `videos` ( `id`, `Title`, `Description` , `code`) VALUES (" & picid + 1 & ",'" & replace(Request("Title"),"'","''") & "', '" & replace(Request("Description"),"'","''") & "', '" & mid(Request("code"),instr(Request("code"),"http://www.youtube.com/v/") + 25,var3) & "')"
When I run this I get an invalid use of mid error
__________________
Today the world, tomorrow the universe...
|

November 30th, 2012, 10:33 AM
|
|
|
Build your MYSQL variable in some smaller chunks, it makes it easier to debug
Code:
e.g.,
mysql = "some stuff"
mysql = mysql & "some more stuff"
mysql = mysql & mid("more stuff", 2, 4)
Something like this keeps the mid function isolated, and if there's a problem with the function, being isolated on one line in your code makes it much easier to find the error.
__________________
======
Doug G
======
It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi
|

November 30th, 2012, 11:19 AM
|
|
Contributing User
|
|
Join Date: Jan 2004
Location: Budapest
|
|
As an afterthought I think what might be easier is this.
First use instr to see if their is an & character. If not then simply do a replace on the string to get rid of http://....etc. leaving just the snippet of code I am after.
If there is an & in the string, then use a string function to trim off everything from the & forward, then use the replace function again to get rid of the http://... etc.
Make sense?
Quote: | Originally Posted by Doug G Build your MYSQL variable in some smaller chunks, it makes it easier to debug
Code:
e.g.,
mysql = "some stuff"
mysql = mysql & "some more stuff"
mysql = mysql & mid("more stuff", 2, 4)
Something like this keeps the mid function isolated, and if there's a problem with the function, being isolated on one line in your code makes it much easier to find the error. |
|

February 8th, 2013, 02:26 AM
|
|
Registered User
|
|
Join Date: Feb 2013
Posts: 1
Time spent in forums: 28 m 9 sec
Reputation Power: 0
|
|
|
Need to convert ASP base Function into PHP
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|