I have a PHP array that I am saving to a MySQL Database:

我有一个PHP数组,我将其保存到MySQL数据库:

 $q35list = serialize($_POST["q35list"]);

Using mysqli_prepare I am saving successfully to the database.

使用mysqli_prepare我成功保存到数据库。

What is odd is that I have a mix of data being stored:

奇怪的是我存储了混合数据:

s:0:""; - fine as user has not selected anything.

S:0: “”; - 很好,因为用户没有选择任何东西。

s:55:"Set[]=6&Set[]=4&Set[]=3&Set[]=7&Set[]=2&Set[]=5&Set[]=1"; - fine as user has selected options and this appears correctly saved.

S:55: “设定[] = 6&设定[] = 4&设定[] = 3&设定[] = 7&设定[] = 2&集[] = 5&集[] = 1”; - 用户选择了选项后显示正常,并且显示正确保存。

But, I am getting a few odd ones, that I can neither replicate or understand how/what/why this is being saved:

但是,我得到了一些奇怪的东西,我无法复制或理解如何/为什么/为什么要保存它:

s:4:"s:4:"; s:5:"s:55:"; s:4:"s:8:";

S:4: “S:4:”; S:5: “S:55:”; S:4: “S:8:”

Has anyone come across this/ know what this might be and would be kind enough to provide an explanation?

有没有人遇到这个/知道这可能是什么,并会很友好地提供解释?

1 个解决方案

#1


2

its hard to say what happend here but it looks like a double serialisation with errors.

很难说这里发生了什么,但它看起来像一个有错误的双序列化。

The most common way to avoid problems with serialisation is to base64 encode after serialisation before save to db:

避免序列化问题的最常见方法是在保存到db之前进行序列化后的base64编码:

//serialize
$string = base64_encode(serialize($array));

//unserialize
$array = unserialize(base64_decode($string));

更多相关文章

  1. mysql 数据库整体运行状态确认思路
  2. 有没有办法确定是由Web应用程序(php进程)执行数据库行更新,还是通过
  3. 是否有人将数据库数据存储在PHP $ _SESSION中?
  4. Wordpress数据库类- MySQL类型。
  5. 向数组添加一组数据库列的问题
  6. c#操作mysql事务是不是要在一个数据库连接内完成?
  7. 如何在MySQL数据库和JPA中使用Spring Boot?
  8. 无法连接远程MySQL数据库的解决方案
  9. MySql数据库安装

随机推荐

  1. android notes(1)
  2. android 自定义组件圆形边框
  3. Ubuntu 将adb加入环境变量
  4. Android控件常用属性
  5. android 去掉应用程序自带的黑色的头部横
  6. Android架构图
  7. Android中 Rect类
  8. Android:SeekBar和RatingBar控件
  9. Android 安装环境搭建
  10. Android笔记--短信与拨号