Php mysql\u real\u escape\u string()希望参数1为字符串,

Php mysql\u real\u escape\u string()希望参数1为字符串,,php,mysql,Php,Mysql,我使用了mysql\u real\u escape\u string,但它会给出以下错误: 警告:mysql_real_escape_string()希望参数1是字符串,数组在第16行的/Applications/XAMPP/xamppfiles/htdocs/example/infostud.php中给出 第16行 您好,如果您的页面上有html或表单发送此值 page.html <html> <head><title>title</title>

我使用了
mysql\u real\u escape\u string
,但它会给出以下错误:

警告:mysql_real_escape_string()希望参数1是字符串,数组在第16行的/Applications/XAMPP/xamppfiles/htdocs/example/infostud.php中给出 第16行


您好,如果您的页面上有html或表单发送此值 page.html

<html>
<head><title>title</title>
</head>
<body>
<hr>
<form action="page_to_process.php" method="post">
name:<br>
<input name="name" id="name" type="text" size=50>
<br>addres:<br>
<input name="addres" id="addres" type="text"size=50>
<br>phone:<br>
<input name="phone" id="phone" type="text" size=50>
<br>
<p>
  <input type="submit"  value="send" id="send" name="send">
</p>
</form>
</body>
</html>

标题

名称:

地址:

电话:

然后,您在需要接收值的页面上创建以下值:

page_to_process.php

<?php
if (isset($_POST['send']))
{   
$name   = mysql_real_escape_string($_POST['name']);
$addres = mysql_real_escape_string($_POST['addres']);
$phone  = mysql_real_escape_string($_POST['phone']);
}

将字符串包装在
[]
中,使其成为包含该字符串值的数组,而不仅仅是字符串。。。。因此,修复它,然后停止使用旧的MySQL扩展,转而使用21世纪的数据库接口,如MySQLi或PDOuse MySQLi或PDO,而不是MySQL$department=MySQL_real_escape_string($_POST['department']);事实上,切换到PDO或MySQLi
<?php
if (isset($_POST['send']))
{   
$name   = mysql_real_escape_string($_POST['name']);
$addres = mysql_real_escape_string($_POST['addres']);
$phone  = mysql_real_escape_string($_POST['phone']);
}