2013-11-15 109 views
0

如何保证小数?在Mysql中,我有type = Decimal value = 6,2。预先感谢您的帮助十进制保护php mysql

<li> 
      <label for="price" class="text">Price:</label> 
      <input name="price" type="text" id="price" tabindex="210"/> 
    </li> 

$price = $_POST["price"]; 

$price = mysqli_real_escape_string($connection, $price); 
+0

请切换到[预处理语句(http://bobby-tables.com/php。 html)来防止[SQL注入](https://www.owasp.org/index.php/SQL_Injection)。 –

回答

4

用途:

$price = filter_input(INPUT_POST, 'price', FILTER_VALIDATE_FLOAT); 
+0

谢谢你的时间和答案 –