Bonjour à tous, je vous expliquez quelle est mon problème et espère s'il vous plait être aider.

Je dois stocker un image dans cette base de donnée (renseignement)

Code sql : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
CREATE TABLE IF NOT EXISTS `identite_prevenu` (
  `numero` int(10) NOT NULL AUTO_INCREMENT,
  `nom` varchar(50) DEFAULT NULL,
  `prenom` varchar(50) DEFAULT NULL,
  `sexe` varchar(10) DEFAULT NULL,
  `date_naissance` date DEFAULT NULL,
  `lieu_naissance` varchar(50) DEFAULT NULL,
  `adresse` varchar(100) DEFAULT NULL,
  `fonction` varchar(50) DEFAULT NULL,
  `date_interpelation` date DEFAULT NULL,
  `lieu_interpelation` varchar(50) DEFAULT NULL,
  `auteur_interpelation` varchar(50) DEFAULT NULL,
  `motif` text,
  `note` text,
  `img` blob NOT NULL,
  `extension` varchar(25) NOT NULL,
  PRIMARY KEY (`numero`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

Et voilà mon code

traitement.php

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
   <head>
       <title>Envoyer une image</title>
       <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
       <style type="text/css">
        label {
            display:block;
            width:150px;
            float:left;
        }
       </style>
   </head>
   <body>
 
<?php
  if(isset($_POST['validation'])) {
 
     //Indique si le fichier a été téléchargé
     if(!is_uploaded_file($_FILES['image']['tmp_name']))
        echo 'Un problème est survenu durant l opération. Veuillez réessayer !';
     else {
        //liste des extensions possibles   
        $extensions = array('/png', '/gif', '/jpg', '/jpeg');
 
        //récupère la chaîne à partir du dernier / pour connaître l'extension
        $extension = strrchr($_FILES['image']['type'], '/');
 
        //vérifie si l'extension est dans notre tableau           
        if(!in_array($extension, $extensions))
            echo 'Vous devez uploader un fichier de type png, gif, jpg, jpeg.';
        else {        
 
            //on définit la taille maximale
            define('MAXSIZE', 300000);       
            if($_FILES['image']['size'] > MAXSIZE)
               echo 'Votre image est supérieure à la taille maximale de '.MAXSIZE.' octets';
            else {
                //connexion à la base de données
                try {
                    $bdd = new PDO('mysql:host=localhost;dbname=renseignement', 'root', '');
                } catch (Exception $e) {
                    exit('Erreur : ' . $e->getMessage());
                }
 
                //Lecture du fichier
                $image = file_get_contents($_FILES['image']['tmp_name']);
 
                $req = $bdd->prepare("INSERT INTO identite_prevenu(numero, nom, prenom, sexe, date_naissance, lieu_naissance, adresse, fonction, date_interpelation, lieu_interpelation, auteur_interpelation, motif, note, img, extension) VALUES(:numero, :nom, :prenom, :sexe, :date_naissance, :lieu_naissance, :adresse, :fonction, :date_interpelation, :lieu_interpelation, :auteur_interpelation, :motif, :note, :image, :type)");
                $req->execute(array(
                    'nom' => $_POST['nom'],
                    'prenom' => $_POST['prenom'],
                    'sexe' => $_POST['sexe'],
                    'date_naissance' => $_POST['date_naissance'],
                    'lieu_naissance' => $_POST['lieu_naissance'],
                    'adresse' => $_POST['adresse'],
                    'fonction' => $_POST['fonction'],
                    'date_interpelation' => $_POST['date_interpelation'],
                    'lieu_interpelation' => $_POST['lieu_interpelation'],
                    'auteur_interpelation' => $_POST['auteur_interpelation'],
                    'motif' => $_POST['motif'],
                    'note' => $_POST['note'],
                    'image' => $image,
                    'type' => $_FILES['image']['type']
                    ));
 
                echo 'OK !';
             }
          }
      }
  }
?>
 
    <h1>Envoyer une image</h1>
    <form enctype="multipart/form-data" action="" method="post">
<table border=1>
<tr><td>
<table border=0 align=center>
 
<tr>
    <td><label for="nom">Nom:</label></td>
    <td><input type="text" name="nom" id="nom" ></td>
</tr>
<tr>
    <td><label for="prenom">Prénom:</label></td>
    <td><input type="text" name="prenom" id="prenom" ></td>
</tr>
 
 
<tr>
    <td >
        <label for="sexe">sexe</label></td><td>
       <select name="sexe" id="sexe" >
 
           <option value="Masculin">Masculin</option>
           <option value="Féminin">Féminin</option>
 
       </select>
    </td>
</tr>
 
<tr>
    <td><label for="date_naissance">Date de naissance:</label></td>
    <td><input type="date" name="date_naissance" id="date_naissance" ></td>
</tr>
 
<tr>
    <td><label for="lieu_naissance">Lieu de naissance:</label></td>
    <td><input type="text" name="lieu_naissance" id="lieu_naissance" ></td>
</tr>
 
<tr>
    <td><label for="adresse">Adresse:</label></td>
    <td><input type="text" name="adresse" id="adresse" ></td>
</tr>
 
<tr>
    <td><label for="fonction">Fonction</label></td>
    <td><input type="text" name="fonction" id="fonction" ></td>
</tr>
 
<tr>
    <td><label for="date_interpelation">Date d'interpelation</label></td>
    <td><input type="date" name="date_interpelation" id="date_interpelation" ></td>
</tr>
 
<tr>
    <td><label for="lieu_interpelation">Lieu d'interpelation</label></td>
    <td><input type="text" name="lieu_interpelation" id="lieu_interpelation" ></td>
</tr>
 
<tr>
    <td><label for="auteur_interpelation">Auteur de l'interpelation</label></td>
    <td><input type="text" name="auteur_interpelation" id="auteur_interpelation" ></td>
</tr>
</table></td>
 
<td>
<table border=1>
<TR>
    <TD><label for="motif">Motif</label></TD>
    <TD>
    <TEXTAREA rows="5" cols="100" name="motif" id="motif">
     </TEXTAREA>
    </TD>
</TR>
<TR>
    <TD><label for="note">Note</label></TD>
    <TD>
    <TEXTAREA rows="20" cols="100" name="note" id="note">
     </TEXTAREA>
    </TD>
</TR>
 
<tr>
    <td>    <label for="image">Image :</td><td> </label><input type="file" name="image" id="image" /></td>
 
</tr>
 
<tr>
    <td><label for="validation">Valider : </td><td></label><input type="submit" name="validation" id="validation" value="Envoyer" /></td>
</tr>
<tr>
    <td colspan=2><input type="reset" value="Annuler"></td>
</tr>
</table>
</td></tr>
</table>
</form>
 
</body>
</html>
et j'ai cette erreur

Warning: PDOStatement::execute() [pdostatement.execute]: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in C:\wamp\www\projet_renseignements_2\traitement.php on line 65

.....

Merci d'avance