anderson_catchme Posted September 16, 2014 Share Posted September 16, 2014 (edited) I have a SQL statement which is difficult to use PDO on, it might not even be possible to do. So I'm filtering it like this: $search = $_GET['search']; $search = preg_replace("/[^A-Za-z0-9]/", " ", $search); $search = $mysqli->real_escape_string($search); Will this result in an acceptable level of security? Edited September 16, 2014 by anderson_catchme Quote Link to comment https://forums.phpfreaks.com/topic/291107-how-good-or-bad-is-the-sql-filtering/ Share on other sites More sharing options...
ginerjm Posted September 16, 2014 Share Posted September 16, 2014 How can a statement be 'difficult to use PDO on'? Whatever do you mean? Quote Link to comment https://forums.phpfreaks.com/topic/291107-how-good-or-bad-is-the-sql-filtering/#findComment-1491304 Share on other sites More sharing options...
anderson_catchme Posted September 16, 2014 Author Share Posted September 16, 2014 (edited) How can a statement be 'difficult to use PDO on'? Whatever do you mean? It's a dynamic query for one, so id need to dynamically generate the question marks somehow. I just prefer strongly to filter this one, honestly. I also find PDO harder to debug. Edited September 16, 2014 by anderson_catchme Quote Link to comment https://forums.phpfreaks.com/topic/291107-how-good-or-bad-is-the-sql-filtering/#findComment-1491305 Share on other sites More sharing options...
Jacques1 Posted September 16, 2014 Share Posted September 16, 2014 None of this is a valid reason for giving up a robust solution in favor of some homegrown “filtering” stuff. In fact, this makes absolutely no sense whatsoever. Where are the quotes? Why on earth would you replace non-alphanumerics with spaces? What is the mysqli_real_escape_string() supposed to do when you've already removed all of its target characters? Quote Link to comment https://forums.phpfreaks.com/topic/291107-how-good-or-bad-is-the-sql-filtering/#findComment-1491309 Share on other sites More sharing options...
ginerjm Posted September 16, 2014 Share Posted September 16, 2014 How can you say that pdo is harder to debug? One doesn't debug the interface. One debugs the query statement which is the same regardless of whether you use mysqli or pdo or mssql. Quote Link to comment https://forums.phpfreaks.com/topic/291107-how-good-or-bad-is-the-sql-filtering/#findComment-1491310 Share on other sites More sharing options...
Jacques1 Posted September 16, 2014 Share Posted September 16, 2014 Prepared statements are indeed harder to debug, because there's no complete query at any point. The best you can get is a bunch of information about the parameters via PDOStatement::debugDumpParams(), but this doesn't even print the corresponding values. Quote Link to comment https://forums.phpfreaks.com/topic/291107-how-good-or-bad-is-the-sql-filtering/#findComment-1491315 Share on other sites More sharing options...
anderson_catchme Posted September 16, 2014 Author Share Posted September 16, 2014 I can't use PDO here guys, because of limitation of MYSQL. Not every query supports PDO: Info here: http://stackoverflow.com/questions/13682355/pdo-and-mysql-fulltext-searches Quote Link to comment https://forums.phpfreaks.com/topic/291107-how-good-or-bad-is-the-sql-filtering/#findComment-1491348 Share on other sites More sharing options...
CroNiX Posted September 16, 2014 Share Posted September 16, 2014 That article you linked to says, in an edit, that it was fixed in more recent versions of mysql for AGAINST() pattern. Quote Link to comment https://forums.phpfreaks.com/topic/291107-how-good-or-bad-is-the-sql-filtering/#findComment-1491349 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.