SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Hybrid View

  1. #1
    SitePoint Zealot akohl's Avatar
    Join Date
    May 2001
    Location
    Israel
    Posts
    184
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    asp function and a type mismach error

    I'm getting a type mismatch error with this scrtipt.
    I added the third line
    max_length=cint(max_length)
    to make sure that the max_length
    variable would be numerical so that it would work as an argument in the left(function).I got the same error message with and without this line.

    What did I do wrong here?

    function strEncode(input_str,max_length)
    input_str=trim(input_str)
    max_length=cint(max_length)
    input_str=left(input_str,max_length)
    input_str=replace(input_str,",",",")
    input_str=replace(input_str,"""",""")
    input_str=replace(input_str,"'","'")
    strEncode=input_str
    end function
    sqlstr="SELECT * FROM institutions;"
    rs1.Open sqlstr,con,3,3
    rs1.AddNew
    rs1.fields("date_entered")=date()
    input_str=request.form("text_institution_name")
    input_str=str_Encode(input_str,10) //type mismatch error here.
    rs1.fields("name")=input_str
    rs1.update
    rs1.close

  2. #2
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,123
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Let's start with writing properly encapsulated functions.

    You're calling a few outside objects and that just isn't pretty (won't work if you move this func out of your site or give it to anyone else).

    Next, what is the info you're passing into it? Also, what line is the error on?
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  3. #3
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not exactly the sharpest cookie in hte box are you?

    you call for teh function isnt matching the function name
    Code:
    function strEncode(input_str,max_length) 
    input_str=trim(input_str) 
    max_length=cint(max_length) 
    input_str=left(input_str,max_length) 
    input_str=replace(input_str,",",",") 
    input_str=replace(input_str,"""",""") 
    input_str=replace(input_str,"'","'") 
    strEncode=input_str 
    end function 
    sqlstr="SELECT * FROM institutions;" 
    rs1.Open sqlstr,con,3,3 
    rs1.AddNew 
    rs1.fields("date_entered")=date() 
    input_str=request.form("text_institution_name") 
    input_str=strEncode(input_str,10)
    rs1.fields("name")=input_str 
    rs1.update 
    rs1.close
    try that

  4. #4
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,123
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    try this too

    We encourage tabulation to keep it easy to read

    Originally posted by dhtmlgod
    Code:
    function strEncode(input_str,max_length) 
    	input_str=trim(input_str) 
    	max_length=cint(max_length) 
    	input_str=left(input_str,max_length) 
    	input_str=replace(input_str,",",",") 
    	input_str=replace(input_str,"""",""") 
    	input_str=replace(input_str,"'","'") 
    	strEncode=input_str 
    end function 
    
    sqlstr="SELECT * FROM institutions;" 
    rs1.Open sqlstr,con,3,3 
    rs1.AddNew 
    rs1.fields("date_entered")=date() 
    input_str=request.form("text_institution_name") 
    input_str=strEncode(input_str,10)
    rs1.fields("name")=input_str 
    rs1.update 
    rs1.close
    try that
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  5. #5
    SitePoint Zealot akohl's Avatar
    Join Date
    May 2001
    Location
    Israel
    Posts
    184
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    pretty smart cookie!

    Thanks guys.

    dhtmlgod found the mistake. Works fine now.

  6. #6
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,123
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    He's the pro anyways, I'm just a tag along
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  7. #7
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    me pro? lol lol lol lol

  8. #8
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,123
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Who's the one who gets paid to do it full time? Oh, n/m, both of us
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  9. #9
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    doesnt make us pros, jus makes our employers stoopid


  10. #10
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,123
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    WELL SAID
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright

  11. #11
    I have an opinion...
    Join Date
    Sep 2001
    Location
    Barrie, Ontario
    Posts
    324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Pros, eh? You guys krack me up...
    Egotist: A person more interested in himself than in me.
    KodeKrash - Eidix - Barrie LUG

  12. #12
    SitePoint Wizard silver trophy Jeremy W.'s Avatar
    Join Date
    Jun 2001
    Location
    Toronto, Canada
    Posts
    9,123
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Couldn't you see the sarcasm? *L*
    SVP Marketing, SoCast SRM
    Personal blog: Strategerize
    Twitter: @jeremywright


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •