From 7356c3443f39799adef2f8c803fb44509068c92f Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Wed, 16 Sep 2009 18:38:20 +0200 Subject: [PATCH] =?utf8?q?ADD=20Un=20d=C3=A9but=20d'helper=20pour=20mysql?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- php/mysql_tools.php | 19 ++++++++++++------- php/pages/inscription.php | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/php/mysql_tools.php b/php/mysql_tools.php index 918d6a9..9c1e1c7 100644 --- a/php/mysql_tools.php +++ b/php/mysql_tools.php @@ -2,14 +2,19 @@ # voir : http://us2.php.net/manual/en/function.func-num-args.php -function query($query, $a, $b, $c, $d, $e) +# utiliser mysqli à la place : +# $stmt = $mysqli->prepare("INSERT INTO CountryLanguage VALUES (?, ?, ?, ?)"); +# $stmt->bind_param('sssd', $code, $language, $official, $percent); +function query($query) { - if ($a == null) - return mysql_query($query); - if ($b == null) - return mysql_query(sprintf($query, - is_string($a) ? mysql_real_escape_string($a) : $a - )); + $args = func_get_args(); + foreach ($args as $i => $arg) + if (is_string($arg)) + $args[$i] = mysql_real_escape_string($a); + + array_shift($query, $args); + + return mysql_query(call_user_func_array('sprintf', $args)); } ?> \ No newline at end of file diff --git a/php/pages/inscription.php b/php/pages/inscription.php index cfdd1e7..8f1ad1c 100644 --- a/php/pages/inscription.php +++ b/php/pages/inscription.php @@ -93,7 +93,7 @@ else - email (non-public) + email (non-public, sauf si piratage de la base ^-^´) -- 2.45.2