By reading the contents of a binary file (image) to a $banner
$banner = addslashes (fread (fopen ( $mysql_banner, "r"),filesize($mysql_banner)))
You can then easily put it in a MySQL database table. It works perfect. But when you do a extra step by loading the contents of a binary file (image) to a associative array $final for later insertion from it into the database, a problem appears - that you can not insert it into the database table. Let's put the same content into associative $final
$final["banner"] = addslashes( fread( fopen( $mysql_banner,"r"), filesize($mysql_banner)
and decomposing it into components
while ( list($name, $value) = each($final) ) {**
$values_fields .= "$name, ";
$values .= "'$value', ";
}
$query1 = "INSERT INTO $banery ($values_fields) VALUES('$values')";
$res = mysql_db_query( $db, $query1)**
Although the original $banner and its copy a variable $value (taken from associative array
$final) have the same content, (a binary content of image), only the original $banner can be inserted into database. When I try to insert $value, the following warning is displayed: "- CAN NOT insert into the database. MySQL Insert - Something wrong ..." (enigmatic hint)
Why?enter code here
mysql_*functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which. If you choose PDO, here is a good tutorial.