function open_close_sondage($id) { if (!isset($_SESSION[CONNECTED])) { return ERROR_NOT_CONNECTED; } if (!is_numeric($id)) { return ERROR_CORRUPTED_DATA; } $bd = new mysqlObject(HOST, DB, USER, MDP); $req = 'select * from sondage where id_sondage = ' . $id . ' and id_user = '******';'; $s = $bd->select($req); if (count($s) != 1) { return ERROR_NOT_YOUR_SONDAGE; } if ($s[0]->STATUS == OPEN) { $stat = CLOSE; } else { $stat = OPEN; } $req = 'update sondage set status = ' . $stat . ' where id_sondage = ' . $s[0]->ID_SONDAGE . ';'; return $bd->execQuery($req); }