Hello everyone!
I'm building a site about all the states of the world..... in the DB (MySql), I'm
going to insert many dates:
id, country,a, lot,of,informations,about,the,country and the image of the map of the
country and pf the flag.
The code I use to put into my db the image is this (see under) and it works...but when
I try to display the image I get this string:
What's wrong??????????????????
[EMAIL
PROTECTED],@?Ç??Ó???H???*\È?Ã#J?H??Å+?Q`ÇI?dI9?LÉä-?Ê93&Í6sÂY?'N?:{
?F?]Z?iD?&??D???ÕX?jÝ?+B?RMR?ÙhÓ?äpãK?+ÛÞÝ??_?wÛ?????W?#K?L??eËÕ?Ê?çñ?bM?Æ??ë?î?sÓ?x6ïs
"Æ?PFãViåÂa?\v?Ö^?)fV`?iæ??æÚ_?pÆÝrÖ??vÆ?râ]&ê?Ò(r??Wh_?ÎâF
i??E??sHZÚ?è?? ???a??è?jx???.??æ??H????Hk??Þë?yèÞà?*??????ÊAv
íM{]?x??ê"??îB×míä???ðb?Ñ/a?Æo???\?Næç?òÃ &1?êwì
?,òlò?òì0Ç?ËÖóé<ÇsÏ{?6tÑ?s%?J~>M??
I??~U??í]??uØ?m6Õ?Í?M?m(ÛÇÜ×ÖvçÝ?ß>?jm?í???W???.9á$î??yp?ëçÞäÎ?ñè^!ëê?ì.ßMÙk??Å2F?RËÅñ?ïÕ??ß??Ôg;[EMAIL
PROTECTED](X?~Ë?ná'? ?0\t` ÅÃ???ËÆ??PIJâ?È!i
yP?UázÕfÕ}5!a?)×?3???????Ë_\ÑÙV?k?:+C?Þ??åahZ??V??]??äÆf???!-
[?Ö?rM?Õg?êÆ? .S??V?Hp?È`t/[[ÛT?[ .rdkÞV?x=
wW7]Ï???kÙ???Ô.sg?W????ÞÕ???ÖF(N??????'Láx2
Î??ÉÃ?\<ÞÉ%%??ç?1ÄÝÕS6^???b"?H+?H?,dw??b???wF?c1Â?_ar??\d"???k?RÖ??Ü&??G?òe'sÙÅ&??*çÙxÎ??!?ARDIV
5.0 ! ;
--------------------------------------------------------------------------------------Code
to insert the image in the
DB-------------------------------------------------------------------------
<?Php
if(!isset($_POST)) $_POST = $HTTP_POST_VARS;
$self = isset($_SERVER) ? $_SERVER["PHP_SELF"] : $HTTP_SERVER_VARS["PHP_SELF"];
if($_POST["invia"]) {
//Definisco le variabili
$host = "localhost";
$user = "bubusettete";
$password = "";
$nomedb = "schedestati";
$tabella = "stati";
$stato = "Italia";
// Mi connetto a MySql e seleziono il database
$connessione = mysql_connect($host,$user,$password) or die ("Non mi riesco a
connettere al database");
mysql_select_db($nomedb, $connessione) or die ("Non riesco a selezionare il db
specificato");
$data = addslashes(fread(fopen($_FILES["file_binario"]["tmp_name"], "rb"),
$_FILES["file_binario"]["size"]));
$nomefile = $_FILES["file_binario"]["name"];
$sizefile = $_FILES["file_binario"]["size"];
$typefile = $_FILES["file_binario"]["type"];
$result = @mysql_query("
UPDATE $tabella
SET
dati_binari_cartina = \"$data\",
nome_carta_stato = \"$nomefile\",
dimensione_carta_stato = \"$sizefile\",
tipo_carta_stato = \"$typefile\"
WHERE stato ='$stato'
") or die("Query di inserimento fallita !");
echo "Il file " . basename($_FILES["file_binario"]["name"]) . " Ã stato correttamente
inserito nel Database.";
@mysql_close();
} else {echo
"<html>
<head>
<title>Form per l'inserimento</title>
</head>
<body>
<div align=\"center\">
<table>
<form action=\"$self\" method=\"POST\" enctype=\"multipart/form-data\">
<tr>
<td>File</td>
<td><input type=\"file\" name=\"file_binario\" size=\"40\"></td>
</tr>
<tr>
<td colspan=\"2\" valign=\"bottom\" align=\"center\" height=\"30\">
<input type=\"submit\" value=\"Invia il file\" name=\"invia\">
</td>
</tr></form>
</table></div></body></html>
";}
?>
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------Code
to diplay the
image------------------------------------------------------------------------------------
<?
// -------------------------------- Modulo per la visualizzazione dei dati di un
database -------------------------------//
$host = "localhost";
$user = "bubusettete";
$password = "";
$nomedb = "schedestati";
$tabella = "stati";
$stato = "Italia";
// Mi connetto a MySql e seleziono il database
$connessione = mysql_connect($host,$user,$password) or die ("Non mi riesco a
connettere al database");
mysql_select_db($nomedb, $connessione) or die ("Non riesco a selezionare il db
specificato");
// Query SQL per selezionare tutti i record della tabella
$sql = "
SELECT *
FROM $tabella
WHERE stato='$stato'
";
// Inserisco in un array tutte le voci del record che ha quel nome di stato
$elencodati = mysql_query($sql,$connessione) or die ("Impossibile avviare la query");
while($riga = mysql_fetch_array($elencodati)){
$stato = $riga['stato'];
$lingua = $riga['lingua'];
$area = $riga['area'];
$id = $riga['id'];
$immagine = $riga['dati_binari_cartina'];
$tipo = $riga['tipo_carta_stato'];
}
// Stampo le voci dell'array
echo "$stato <br />";
echo "$lingua <br />";
echo $immagine;
?>
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------