Erreur en exécutant une requête mysql_query()
lorsque j’exécute ce code il affiche ce message :
Citation:
error ;Warning: mysql_query() expects parameter 2 to be resource,
Code:
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
| <?php
function db_query($db_name, $sql) {
$sql = str_replace("# ", "", $sql); // basic shield against sql injections
$sql = str_replace("#' ", "", $sql);
global $db_connection_type, $db_server_address, $db_user, $db_password;
switch($db_connection_type) {
case "odbc":
$db_connection = odbc_connect($db_name, $db_user, $db_password);
$result = odbc_exec($db_connection, $sql);
break;
case "mysql":
$db_connection = new mysqli($db_server_address, $db_user, $db_password);
$result = mysql_query ($sql, $db_connection) or die (mysql_error()); ;
// ($db_name, $sql, $db_connection);
}
return $result;
}
function fetch_array($array) {
global $db_connection_type;
switch($db_connection_type) {
case "odbc":
$result = odbc_fetch_array($array);
break;
case "mysql":
$result = mysql_fetch_array($array);
}
return $result;
}
?> |
Merci