redarrow Posted September 13, 2006 Share Posted September 13, 2006 advance thank you.i have read that most good programmers make a function to addslases stripslashes and trimis the following possable.[code]<?php$redarrow=stripslashes(addslashes(trim($_POST['redarrow'])));?>[/code] Quote Link to comment Share on other sites More sharing options...
yungbloodreborn Posted September 13, 2006 Share Posted September 13, 2006 I'm sure that's possible, I've nested function calls like that before in PHP. But I fail to see the reason for putting addslashes in a stripslashes call with nothing in between.-YB Quote Link to comment Share on other sites More sharing options...
gijew Posted September 13, 2006 Share Posted September 13, 2006 Yeah, what you're doing there is effectively this...stripslashes from the stringadding slashes to the stringtriming white space from the stringDon't take them away and then put them back. Other then that, you would have no issues combining functions together to do that for you. IMHO it would be best to put those inside of your own function so you could call it whenever you wanted to like this...function cleanString($String) { return addslashes(trim($String));}Just use like this...echo cleanString($_POST['redarrow']); Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 13, 2006 Author Share Posted September 13, 2006 see i understand the concept that wht i asked as you no i am only asking as seen on here and wondered.now as you have provided a good example of the function format i want to no is it possable to make up somethink in the function that will cheek all the varables but as one value and not hundreds. Quote Link to comment Share on other sites More sharing options...
gijew Posted September 13, 2006 Share Posted September 13, 2006 Are you putting numbers into the function? If so you should use use something else...if you're trying to round just use the round() function. Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted September 13, 2006 Share Posted September 13, 2006 [code]<?php // MakeDBSafe // $val - the value to make safe for insertion into the database // RETURN: $val modified to be safe for insertion into a database function MakeDBSafe($val){ if(!is_numeric($val)){ $val = "'" . trim(addslashes($val)) . "'"; } return $val; }?>[/code] Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted September 13, 2006 Share Posted September 13, 2006 I reread your last post, if you're asking is there a generic function that you can write that will validate any and all data, yes you can. It will be long, ugly, and messy. I'd recommend several smaller sections and possibly taking advantage of regexps for that. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.