ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Closed Thread
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 30th, 2012, 09:07 AM
thall89553 thall89553 is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2004
Location: Budapest
Posts: 1,702 thall89553 User rank is Second Lieutenant (5000 - 10000 Reputation Level)thall89553 User rank is Second Lieutenant (5000 - 10000 Reputation Level)thall89553 User rank is Second Lieutenant (5000 - 10000 Reputation Level)thall89553 User rank is Second Lieutenant (5000 - 10000 Reputation Level)thall89553 User rank is Second Lieutenant (5000 - 10000 Reputation Level)thall89553 User rank is Second Lieutenant (5000 - 10000 Reputation Level)thall89553 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 18 h 38 m 9 sec
Reputation Power: 66
Send a message via Yahoo to thall89553
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...

Reply With Quote
  #2  
Old November 30th, 2012, 10:33 AM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Jun 2003
Posts: 14,239 Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 15 h 20 m 7 sec
Reputation Power: 4445
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

Reply With Quote
  #3  
Old November 30th, 2012, 11:19 AM
thall89553 thall89553 is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2004
Location: Budapest
Posts: 1,702 thall89553 User rank is Second Lieutenant (5000 - 10000 Reputation Level)thall89553 User rank is Second Lieutenant (5000 - 10000 Reputation Level)thall89553 User rank is Second Lieutenant (5000 - 10000 Reputation Level)thall89553 User rank is Second Lieutenant (5000 - 10000 Reputation Level)thall89553 User rank is Second Lieutenant (5000 - 10000 Reputation Level)thall89553 User rank is Second Lieutenant (5000 - 10000 Reputation Level)thall89553 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 5 Days 18 h 38 m 9 sec
Reputation Power: 66
Send a message via Yahoo to thall89553
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.

Reply With Quote
  #4  
Old February 8th, 2013, 02:26 AM
agnes88 agnes88 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 1 agnes88 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 9 sec
Reputation Power: 0
Need to convert ASP base Function into PHP

Reply With Quote
Closed Thread

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Help w/ ASP Mid Function Please

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap