Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 取消序列化通过mysqli_real_escape_string()和serialize()函数传递的字符串值_Php_Mysql - Fatal编程技术网

Php 取消序列化通过mysqli_real_escape_string()和serialize()函数传递的字符串值

Php 取消序列化通过mysqli_real_escape_string()和serialize()函数传递的字符串值,php,mysql,Php,Mysql,我通过mysqli_real_escape_字符串传递$post变量,并在PHP中序列化函数,如下所示: $post = mysqli_real_escape_string($db_connect, serialize($item)); 然后我在MySQL数据库中插入了$post值。存储的数据在数据库中的格式如下所示: a:1:{s:9:"title";s:37:"This is just a test -Title";} 或 如何在将$post变量插入数据库之前仅生成文本值,即这只是一个测

我通过mysqli_real_escape_字符串传递$post变量,并在PHP中序列化函数,如下所示:

$post = mysqli_real_escape_string($db_connect, serialize($item));
然后我在MySQL数据库中插入了$post值。存储的数据在数据库中的格式如下所示:

a:1:{s:9:"title";s:37:"This is just a test -Title";}

如何在将$post变量插入数据库之前仅生成文本值,即这只是一个测试标题,而不是:1:{s:9:Title;s:37:这只是一个测试标题;}

在将信息插入数据库之前,不需要序列化变量;您只需转义该值:

$post = mysqli_real_escape_string($db_connect, $item["title"]);
然后在查询中使用$post插入值。这将导致在数据库中只保留值。

在将信息插入数据库之前,不需要序列化变量;您只需转义该值:

$post = mysqli_real_escape_string($db_connect, $item["title"]);

然后在查询中使用$post插入值。这将导致在数据库中只保留值。

您可以简单地从数组中取出元素,直接将其插入数据库,而不是序列化数组。别忘了清理你的变量

mysqli_real_escape_string($db_connect, $item['title']);

不用序列化数组,只需从数组中取出元素,直接将其插入数据库即可。别忘了清理你的变量

mysqli_real_escape_string($db_connect, $item['title']);
$item的格式是什么?@BadWolf,$item的格式是数组[title]=>这只是一个使用简单HTML dom库生成的测试标题;那么,$item的格式是什么?@BadWolf,$item的格式是数组[title]=>这只是一个使用简单HTML dom库生成的测试标题;然后