ravix76 Posted May 12, 2007 Share Posted May 12, 2007 Anyone got a pointers to tutorials for checking large chunks of text. I'm fine with the preg_replace command on smaller items (eg checking id's are numbers only etc) but my website requires product manufacturers to cut and paste large chunks of text into an uploadable form. I want to check this (SQL Injection) before inserting it into the SQL database but I'm running into probs with text containing " and `. Here's where I'm at... gotta be an easier way? $pattern="/[^A-Za-z0-9\-\%\.\,\!\(\)\[\]\{\}\:\;\'\"\$\/\^\&\<\>\?\@\_\+\=\ \ ]/"; // Pattern to validate against if (preg_match($pattern, $producttext)) { exit ("Error: Invalid Characters Found In Product Text"); // Stop Script } I believe my server / host has MagicQuotes turned on (if it matters) Quote Link to comment Share on other sites More sharing options...
effigy Posted May 13, 2007 Share Posted May 13, 2007 If your only concern is SQL injection, simply run the string through mysql_real_escape_string (assuming that you're using MySQL). Otherwise, you need to define your other concerns: do you need to worry about HTML tagging? What about XSS? Are you expecting certain formats within the data? 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.