为什么以某种方式分解关联数组更改以前存储的图片?

Let's read the image file into varialble picture:

$picture = addslashes(fread(fopen($image, "r"), filesize($image))); 

This $picture you can easy insert into database table with no trouble.

*for example*:  INSERT INTO $banners(banner) VALUES( $picture );

For some reason lets create an associative array $final:

$final["banner"] = $picture;
$final["place"] = something...

Later lets decompose $final and insert the obtained values into database:

  $fields = "";      $values = "";

  while (list($name, $value) = each( $final ))
  {
        $fields .= "$name, ";
        $values .= "'$value', ";
  }
  // Cut trailing commas
  $values_fields = ereg_replace(", $", "", $values_fields);
  $values = ereg_replace(", $", "", $values);

  // Execute query
  $query = "INSERT INTO banners($values_fields) VALUES($values)";
  $res = mysql_db_query($database, $query) or mysql_die();     

Now MySQL warns "Something wrong" when comes to insert consecutive $value with $picture into database. Why?

If the code you posted here is exactly the one you are trying to run then please note that you are accumulating field names in $fields variable but "cut trailing commas" from $values_fields which is at this point empty. Putting empty $values_fields into your query might be the cause of mysql error.

Why are you doing addslashes()? Try to use mysql_real_escape_string() instead.

Also make sure that the type of the database column where you are trying to put your image into is BLOB or LONGBLOB.

You may find answer to this question Binary Data in MySQL relevant.

First, don't destroy your data. Read it directly and keep the variable clean:

$picture = file_get_contents($image);

Next, prepare the data for insertion:

$final["banner"] = mysqli_real_escape_string($picture);
$final["place"]  = $something;

Last, there is no need to loop through your array, since it only contains one record. You don't quote the values, causing an error.

$fields = "`" . implode("`, `", array_keys($final)) . "`";
$values = "'" . implode("', '", array_values($final)) . "'";

$query  = "INSERT INTO banners ({$fields}) VALUES ({$values})";
$result = mysqli_query($database, $query) or die(mysqli_error($database));

I'm using MySQLi here, since the mysql_* functions are deprecated (as well as ereg_* functions).