添加 mysql_real_escape_string() 会导致将空白值存储到数据库中
$submit=$_POST['submit'];
$fullname=$_POST['fullname'];
$phone=preg_replace('/[^0-9]/', '', $_POST['phone']);
$phone = (int) $phone;
$adress=$_POST['city'] . ' ' . $_POST['district'] . ' ' . $_POST['adress'];
$friends=$_POST['friends'];
$school=$_POST['school'];
$info=$_POST['info'];
$dob = $_POST['year']."-". $_POST['month']."-".$_POST['day'];
最近我添加到我的页面:
foreach ($_POST as $key => $value) {
$_POST[$key] = mysql_real_escape_string($value);
}
我想清理所有 $_POST (http://prntscr.com/22uot)添加 mysql_real_escape_string()
到我的页面之前的 ID 20,之后的 id 22。我的页面将所有变量放入数据库表的字段中,但是当我想将 mysql_real_escape_string() 添加到变量时,它不会将任何内容放入该字段中。我不知道该怎么办。
$submit=$_POST['submit'];
$fullname=$_POST['fullname'];
$phone=preg_replace('/[^0-9]/', '', $_POST['phone']);
$phone = (int) $phone;
$adress=$_POST['city'] . ' ' . $_POST['district'] . ' ' . $_POST['adress'];
$friends=$_POST['friends'];
$school=$_POST['school'];
$info=$_POST['info'];
$dob = $_POST['year']."-". $_POST['month']."-".$_POST['day'];
Recently i added to my page:
foreach ($_POST as $key => $value) {
$_POST[$key] = mysql_real_escape_string($value);
}
i want to sanitize all $_POST's (http://prntscr.com/22uot) ID 20 before adding mysql_real_escape_string()
to my page, id 22 after. My page puts all variables to db table's fields but when I want to add mysql_real_escape_string()
to variable it puts nothing into the field. I dunno what to do.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如 手册 中明确指出的(这是第一个如有疑问,您应该浏览的内容):
在使用此功能之前,请确保您已连接到数据库。
As clearly indicated in the manual (which is the first things you should browse, when in doubt):
Be sure you've connect to your database before using this function.
要使用此功能,您必须先打开与数据库的连接,例如:
to use this function, you must have a connection opened to your database before, like :