Bonjour, j'utilise une class Mydb dont voici le code :
Lorsque dans une page j'ai par exemple :
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 <?php class MyDb { protected $mysqli; function __construct() { require_once('includes/password.inc.php'); $this->mysqli = @new mysqli($db_host, $db_user, $db_pass, $db_name); if ( mysqli_connect_error() ) { perror(mysqli_connect_error()); $this->mysqli = FALSE; //exit(); } } function __destruct() { $this->close(); } function close() { if ( $this->mysqli ) { $this->mysqli->close(); $this->mysqli = FALSE; } } function queryObjectArray($sql) { if ( $result = $this->mysqli->query($sql) ) { if ( $result->num_rows ) { while ( $row = $result->fetch_assoc() ) $tab_result[] = $row; $result->close(); return $tab_result; } else { $result->close(); return FALSE; } } else { perror($this->mysqli->error); $this->close(); return FALSE; } } function querySingleItem($sql) { if ( $result = $this->mysqli->query($sql) ) { if ( $row = $result->fetch_row() ) { $result->close(); return $row[0]; } else { $result->close(); return -1; } } else { perror($this->mysqli->error); $this->close(); return -1; } } function queryFieldsArray($sql) { if ( $result = $this->mysqli->query($sql) ) { $forminfo = $result->fetch_fields(); for($i=0; $i<=count($forminfo); $i++) { $info[$forminfo[$i]->name] = $forminfo[$i]; } $result->close(); return $info; } else { perror($this->mysqli->error); $this->close(); return FALSE; } } function execute($sql) { if ( $this->mysqli->real_query($sql) ) return TRUE; else { perror($this->mysqli->error); $this->close(); return FALSE; } } function insert_id() { return $this->mysqli->insert_id; } } ?>
J'obtient le message suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 $db = new MyDb; $db->close(); $db = new MyDb;
Est-ce que quelqu'un a une idée d'ou peux prevenir cette erreur ?
Code : Sélectionner tout - Visualiser dans une fenêtre à part Access denied for user 'ODBC'@'localhost'
Partager