我使用了mysql_real_escape_string,但是会出现以下错误:


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


$department=mysql_real_escape_string(['department']);

最佳答案

您好,如果您在页面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']);
}


那么您在$ name,$ addres,$ phone上具有值

为此,您有一些方法发布,让我更喜欢发布

尝试并祝你好运... !!!

10-04 21:44
查看更多