title: Base64 as method of sanitizing user input for Mysql
body: <p>I would assume that the only way to guarantee that a user input is mysql safe is to use either a whitelist where you only allow mysql safe input, or by encoding the input into something that will always return mysql safe. Base64 seams to me like one candidate for such an encoding, along with mysql_escape_string... Is there any reason besides user readability that one should not use Base64 for input sanitation? Is it considered bad practice? I also have a sense that all the filtering of user data to ensure proper safety could have been easier to achieve if the problem was handled by mysql rather then relying on the individual programmer to ensure that the data is safe... For example by using individual functions rather than a query based string, so that the command and user input remains separate throughout the call... </p>
  
  <pre><code>Like: mysql_query("SELECT * FROM Users WHERE username=","$userinput");
  </code></pre>
  
  <p>Alternatively one could use encoding:</p>
  
  <pre><code>$input = encode($_POST['UserInput']);
  mysql_query("SELECT * FROM Users WHERE username='$input'");
  </code></pre>