PHP - Otro error-otro archivo

 
Vista:
sin imagen de perfil
Val: 18
Ha aumentado su posición en 6 puestos en PHP (en relación al último mes)
Gráfica de PHP

Otro error-otro archivo

Publicado por RED HORMIGAS (10 intervenciones) el 13/07/2019 00:32:10
Ahora esto tiene al especial el unico error que tiene es la ultima llave.

AQUI ESTA EL MENSAJE QUE ME MUESTRA EL ERROR
Warning: Declaration of DB_mysqli::query($resource) should be compatible with mysqli::query($query, $resultmode = NULL) in C:\wamp64\www\xNova\includes\classes\class.MySQLi.php on line 261

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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<?php
 
class DB_mysqli extends mysqli
{
   protected $con;
   protected $exception;
 
   /**
    * Constructor: Set database access data.
    *
    * @param string   The database host
    * @param string   The database username
    * @param string   The database password
    * @param string   The database name
    * @param integer   The database port
    *
    * @return void
    */
   public function __construct($exception = true)
   {
      $this->con         = $GLOBALS['database'];
      $this->exception   = $exception;
 
        if (!isset($this->con['port'])) {
            $this->con['port'] = 3306;
        }
 
      @parent::__construct($this->con['host'], $this->con['user'], $this->con['userpw'], $this->con['databasename'], $this->con['port']);
 
      if(mysqli_connect_error())
      {
         if($this->exception == true)
            throw new Exception("Connection to database failed: ".mysqli_connect_error());
         elseif(defined('INSTALL'))
            return false;
      }
      parent::set_charset("utf8");
      parent::query("SET SESSION sql_mode = '';");
   }
 
   /**
    * Close current database connection.
    *
    * @return void
    */
   public function __destruct()
   {
      if(!mysqli_connect_error())
         parent::close();
   }
 
   /**
    * Purpose a query on selected database.
    *
    * @param string   The SQL query
    *
    * @return resource   Results of the query
    */
   public function query($resource)
   {
      if($result = parent::query($resource))
      {
         $this->queryCount++;
         return $result;
      }
      else
      {
         if($this->exception == true) {
            throw new Exception("SQL Error: ".$this->error."<br><br>Query Code: ".$resource);
         } else {
            return "SQL Error: ".$this->error;
         }
      }
        return false;
   }
   /**
    * Purpose a query on selected database.
    *
    * @param string   The SQL query
    *
    * @return resource   Results of the query
    */
 
   public function uniquequery($resource)
   {
      $result = $this->query($resource);
      $Return = $result->fetch_array(MYSQLI_ASSOC);
      $result->close();
      return $Return;
 
   }
   /**
    * Purpose a query on selected database.
    *
    * @param string   The SQL query
    *
    * @return resource   Results of the query
    */
 
   public function countquery($resource)
   {
      $result = $this->query($resource);
      list($Return) = $result->fetch_array(MYSQLI_NUM);
      $result->close();
      return $Return;
   }
   /**
    * Purpose a query on selected database.
    *
    * @param string   The SQL query
    *
    * @return resource   Results of the query
    */
 
   public function fetchquery($resource, $encode = array())
   {
      $result = $this->query($resource);
      $Return   = array();
      $Col   = 0;
      while($Data   = $result->fetch_array(MYSQLI_ASSOC)) {
         foreach($Data as $Key => $Store) {
            if(in_array($Key, $encode))
               $Data[$Key]   = base64_encode($Store);
         }
         $Return[]   = $Data;
      }
      $result->close();
      return $Return;
   }
 
   /**
    * Returns the row of a query as an array.
    *
    * @param resource   The SQL query id
    *
    * @return array   The data of a row
    */
   public function fetch_array($result)
   {
      return $result->fetch_array(MYSQLI_ASSOC);
   }
 
   /**
    * Returns the row of a query as an array.
    *
    * @param resource   The SQL query id
    *
    * @return array   The data of a row
    */
   public function fetch_num($result)
   {
      return $result->fetch_array(MYSQLI_NUM);
   }
 
   /**
    * Returns the total row numbers of a query.
    *
    * @param resource   The SQL query id
    *
    * @return integer   The total row number
    */
   public function num_rows($query)
   {
      return $query->num_rows;
   }
 
   /**
    * Returns the total row numbers of a query.
    *
    * @param resource   The SQL query id
    *
    * @return integer   The total row number
    */
   public function GetInsertID()
   {
      return $this->insert_id;
   }
 
   /**
    * Escapes a string for a safe SQL query.
    *
    * @param string The string that is to be escaped.
    *
    * @return string Returns the escaped string, or false on error.
    */
 
    public function sql_escape($string, $flag = false)
    {
      return ($flag === false) ? parent::escape_string($string): addcslashes(parent::escape_string($string), '%_');
    }
 
   public function str_correction($str)
   {
      return stripcslashes($str);
   }
 
   /**
    * Returns used mysqli-Verions.
    *
    * @return string   mysqli-Version
    */
   public function getVersion()
   {
      return parent::get_client_info();
   }
 
   /**
    * Returns used mysqli-Verions.
    *
    * @return string   mysqli-Version
    */
   public function getServerVersion()
   {
      return $this->server_info;
   }
 
   /**
    * Frees stored result memory for the given statement handle.
    *
    * @param resource   The statement to free
    *
    * @return void
    */
   public function free_result($resource)
   {
      return $resource->close();
   }
 
   public function multi_query($resource)
   {
      $Timer   = microtime(true);
      if(parent::multi_query($resource))
      {
         do {
             if ($result = parent::store_result())
               $result->free();
 
            $this->queryCount++;
 
            if(!parent::more_results()){break;}
 
         } while (parent::next_result());
      }
 
      $this->SQL[]   = $resource;
 
      if ($this->errno)
      {
         if($this->exception == true) {
            throw new Exception("SQL Error: ".$this->error."<br><br>Query Code: ".$resource);
         } else {
            return "SQL Error: ".$this->error;
         }
      }
   }
 
   public function get_sql()
   {
      return $this->queryCount;
   }
}
 
?>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
Imágen de perfil de Mauro
Val: 2.761
Oro
Ha aumentado 1 puesto en PHP (en relación al último mes)
Gráfica de PHP

Otro error-otro archivo

Publicado por Mauro (1036 intervenciones) el 13/07/2019 15:56:05
El problema es que estás sobre-escribiendo el método query de la clase mysqli con una versión que no tiene la misma firma que la de la super clase.

Debes cambiar tu método query para que reciba los mismos parámetros que el de la clase base (mysqli) o cambiarle el nombre (para que no lo sobre-escriba).

Tal vez te convenga leer un poco más sobre POO con PHP. Este libro puede ayudarte.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar