Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Please help me "Remove srting" on submit.

Author  Topic 

Breana
Starting Member

6 Posts

Posted - 2007-08-18 : 11:52:02
Ok, my host is free and for some reason when my users submit there code inside the discreption "textarea" with this (don't) it crashes the form without sending it to the database?
But if it is sent like this (dont) its ok!

So i am working on replacing the invalid strings so it'll be ok if they forget not to do it. But i am stuck...

    Function CleanInput(strIn As String) As String
' Replace invalid characters with empty strings.
Return Regex.Replace(strIn, "[^\w\.@-]", "")
End Function


Any help i will love you forever :P

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-08-18 : 11:55:39
replace one ' with two ' and you'll be ok.

' is a text start and end identifier so if you want to have it in text you have to escape it.
escaping it is done by doubling it.

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

Breana
Starting Member

6 Posts

Posted - 2007-08-18 : 12:01:22
I have no clue i found this online i just need a simple way so if the form is submited it will remove all the (@ ') bad charecters.

I also found this but not shure how to use it...
<%
NewVal = TRIM(OldVAl)
NewVal = Replace(OldVal,"$","")
%>
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-08-18 : 12:11:59
what is your frond end programming language? C#, VB.net, ASP?

as i said you just have to replace each single quote to two single quotes in your text.

you are using Microsoft SQL Server, right? and not MySql or some other?

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

Breana
Starting Member

6 Posts

Posted - 2007-08-18 : 12:17:44
Ok the form is with php 4+
and it is sending it to MySQL.
5+ i think.

Go to Top of Page

Breana
Starting Member

6 Posts

Posted - 2007-08-18 : 12:44:17
What is the best way to do this simple i hope :)
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-08-18 : 13:23:45
well since you're using MySql you should ask a question at a mysql forum
http://forums.mysql.com/

very few people here have experience with php and MySql, so you'll get help there faster.


_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-08-20 : 01:52:29
Well. To give you an example, use
select '@kjhsdf''f' as orginal_str,
replace(replace('@kjhsdf''f','@',''),'''','') as valid_str

or use the same logic in php to filter and send only valid data to the table


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -