Esempio n. 1
0
echo("<body>\n");
echo("<div style=\"font-family: 'Lucida Grande', 'Trebuchet MS', Verdana, Helvetica, Arial, sans-serif; font-size: 10px;\">\n");
echo("<b style=\"color: #dd2222;\">DB Conversion to UTF-8 in progress, please do not stop the browser until the whole process is finished...</b><br />\n<br />\n<br />\n");
// HTML HEADER - END
flush();

$sql = "ALTER DATABASE {$db->sql_escape($dbname)}
	CHARACTER SET utf8
	DEFAULT CHARACTER SET utf8
	COLLATE utf8_bin
	DEFAULT COLLATE utf8_bin";
$db->sql_query($sql) or die($db->sql_error());

$sql = "SHOW TABLES";
$result = $db->sql_query($sql) or die($db->sql_error());
while ($row = $db->sql_fetchrow($result))
{
	// This assignment doesn't work...
	//$table = $row[0];

	$current_item = each($row);
	$table = $current_item['value'];
	reset($row);

	if (strpos($table, $table_prefix) === 0)
	{
		$sql = "ALTER TABLE {$db->sql_escape($table)}
			DEFAULT CHARACTER SET utf8
			COLLATE utf8_bin";
			//ENGINE=MYISAM";
		$db->sql_query($sql) or die($db->sql_error());
Esempio n. 2
0
 }
 $sql = "UPDATE " . $table_prefix . "users\n                SET user_regdate = " . time();
 if (!$db->sql_query($sql)) {
     $error .= "Could not update user_regdate :: " . $sql . " :: " . __LINE__ . " :: " . __FILE__ . "<br /><br />";
 }
 // Prillian - START
 $user_success = 0;
 $user_total = 0;
 $err_msg = '';
 $err_ids = array();
 $sql = 'SELECT user_id, user_style FROM ' . $table_prefix . 'users WHERE user_id <> ' . ANONYMOUS;
 if (!($result = $db->sql_query($sql))) {
     $error = true;
     $error .= '<span class="err_msg">Failed to get list of user_ids for inserting<br /><br /></span>';
 }
 while ($row = $db->sql_fetchrow($result)) {
     $user_total++;
     $sql = 'INSERT INTO ' . $table_prefix . 'im_prefs (user_id, themes_id) VALUES (' . $row['user_id'] . ', ' . $row['user_style'] . ')';
     if (!$db->sql_query($sql)) {
         $error = true;
         $err_msg .= (!empty($err_msg) ? ', ' : '') . $row['user_id'];
         $err_ids[] = $row['user_id'];
     } else {
         $user_success++;
     }
 }
 if ($err_msg) {
     $error .= '<br /><br /><span class="err_msg">These users were not copied: ' . $err_msg . '.</span><br /><br />Those users may already exist in the table or the copy may have simply failed. In the latter case, you may need to add the users manually. To do this, you will need to run the SQL queries below through phpMyAdmin or a similar utility. If you do not have such a utility, try going to the Utilities section of phpBBHacks.com and check out the db_generator page there.<br /><br /><span class="query_msg">';
     //foreach($err_ids as $id)
     //{
     //  $message .= 'INSERT INTO ' . $table_prefix . 'im_prefs (user_id, themes_id) VALUES (' . $id . ', ' . $board_config['default_style'] . ');<br />';
Esempio n. 3
0
            if (strlen($valore) > 0) {
                $sqlinsertfield .= "{$campo},";
                $sqlinsertvalues .= "{$valore},";
            }
        }
        $sqlinsertfield = substr($sqlinsertfield, 0, strlen($sqlinsertfield) - 1);
        $sqlinsertvalues = substr($sqlinsertvalues, 0, strlen($sqlinsertvalues) - 1);
        $sqlinsert = "insert into {$tabelladb} ({$sqlinsertfield}) values ({$sqlinsertvalues})";
        $sql = $sqlinsert;
    }
    //echo "<p>$sql</p>";
    print_debug($sql, null, 'savedata');
    $result = $db->sql_query($sql);
    $retval = "";
    $elenco = $db->sql_fetchrowset();
    $nrighe = $db->sql_numrows();
    if (!$result) {
        echo "ERRORE NEL SALVATAGGIO<p>{$sql}</p>";
        return;
    }
    //se ho inserito un nuovo valore ricavo l'ultimo id
    if ($_POST["mode"] == "new") {
        $sql = $tb->table_list ? "SELECT max(id) FROM {$tabelladb}" : "select currval ('" . trim($tabelladb) . "_id_seq')";
        //echo "<p>$sql</p>";
        $db->sql_query($sql);
        $row = $db->sql_fetchrow();
        $lastid = $row[0];
        $_SESSION["ADD_NEW"] = $lastid;
        //print_debug("sessione ho $lastid");
    }
}
require_once "login.php";
$db = new sql_db(DB_HOST, DB_USER, DB_PWD, DB_NAME, false);
if (!$db->db_connect_id) {
    die("Impossibile connettersi al database");
}
$oggi = date("d-m-Y");
$dataoneri = date("d/m/Y");
$pratica = $_REQUEST['pratica'];
$sql = "SELECT numero,coalesce(data_prot,data_presentazione) as data from pe.avvioproc where pratica={$pratica}";
$db->sql_query($sql);
$numero = $db->sql_fetchfield('numero');
//$dataoneri=$db->sql_fetchfield('data');
$query = "SELECT * FROM oneri.parametri where '{$dataoneri}'::date BETWEEN datein AND coalesce(dateed,CURRENT_DATE);";
$result = $db->sql_query($query);
//if(!$result){echo "SQL Error - ".mysql_error()."<br>".$query;return;}
$row = $db->sql_fetchrow($result);
$costo_base = $row['costo_base'];
$qbase = $row['quota_base'];
$classe = $row['classe_comune'];
$quota = $row['corrispettivo'];
$delibera = $row['delibera'];
$sql = "SELECT case when (not coalesce(piva,'')='') then coalesce(ragsoc,'') else coalesce(cognome,'')||' '||coalesce(nome,'') end as nominativo FROM pe.soggetti WHERE richiedente=1 and pratica={$pratica};";
$db->sql_query($sql);
$ris = $db->sql_fetchlist('nominativo');
$nominativi = implode('; ', $ris);
$sql = "SELECT coalesce(via,'')||' '||coalesce(civico,'') as indirizzi FROM pe.indirizzi WHERE pratica={$pratica};";
$db->sql_query($sql);
$ris = $db->sql_fetchlist('indirizzi');
$indirizzi = implode('; ', $ris);
$sql = "SELECT valore,codice FROM pe.parametri_prog X inner join pe.e_parametri Y on(X.parametro=Y.id) WHERE pratica={$pratica} and codice in ('slot','ve','vp')";
//echo $sql;
Esempio n. 5
0
        break;
    case 'postgresql':
        break;
}
$db->sql_query($sql);
$sql = "UPDATE {$table_prefix}topics SET topic_poster = 1 WHERE topic_poster = 0 OR topic_poster IS NULL";
$db->sql_query($sql);
$sql = "UPDATE {$table_prefix}topics SET topic_last_poster_id = 1 WHERE topic_last_poster_id = 0 OR topic_last_poster_id IS NULL";
$db->sql_query($sql);
$sql = "UPDATE {$table_prefix}posts SET poster_id = 1 WHERE poster_id = 0 OR poster_id IS NULL";
$db->sql_query($sql);
$sql = "UPDATE {$table_prefix}users SET user_id = 1 WHERE user_id = 0";
$db->sql_query($sql);
$sql = "SELECT t.topic_id \n\tFROM {$table_prefix}topics t \n\tLEFT JOIN {$table_prefix}posts p ON p.topic_id = t.topic_id \n\tWHERE p.topic_id IS NULL";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result)) {
    $del_sql = '';
    do {
        $del_sql .= ($del_sql != '' ? ', ' : '') . $row['topic_id'];
    } while ($row = $db->sql_fetchrow($result));
    $sql = "DELETE FROM {$table_prefix}topics \n\t\tWHERE topic_id IN ({$del_sql})";
    $db->sql_query($sql);
}
$db->sql_freeresult($result);
$del_sql = '';
$sql = "SELECT topic_id, MIN(post_id) AS first_post_id, MAX(post_id) AS last_post_id, COUNT(post_id) AS total_posts \n\tFROM {$table_prefix}posts \n\tGROUP BY topic_id";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result)) {
    $del_sql .= ($del_sql != '' ? ', ' : '') . $row['topic_id'];
    $sql = "UPDATE {$table_prefix}topics \n\t\tSET topic_first_post_id = " . $row['first_post_id'] . ", topic_last_post_id = " . $row['last_post_id'] . ", topic_replies = " . ($row['total_posts'] - 1) . "\n\t\tWHERE topic_id = " . $row['topic_id'];
    $db->sql_query($sql);
Esempio n. 6
0
// DATABASE
$coddb = new sql_db($db_host, $db_user, $db_pass, $db_db, false);
if (!$coddb->db_connect_id) {
    die("Could not connect to the database");
}
/*$query = "SELECT * 
  FROM ${t['players']}, ${t['b3_clients']} 
  WHERE ${t['b3_clients']}.id = ${t['players']}.client_id 
      AND ${t['players']}.id = '" . addslashes_gpc($player_id) . "'
      AND ((${t['players']}.kills > $minkills)
          OR (${t['players']}.rounds > $minrounds))
      AND (${t['players']}.hide = 0)
      AND ($current_time - ${t['b3_clients']}.time_edit  < $timelimit)";*/
$query = "SELECT * \n          FROM {$t['players']}, {$t['b3_clients']} \n          WHERE {$t['b3_clients']}.id = {$t['players']}.client_id \n              AND {$t['players']}.id = '" . addslashes_gpc($player_id) . "'";
$result = $coddb->sql_query($query);
$player = $coddb->sql_fetchrow($result);
$coddb->sql_query("START TRANSACTION");
$coddb->sql_query("BEGIN");
$coddb->sql_query("SET @place = 0");
$query2 = "select * from (\n             SELECT @place := @place + 1 AS place, {$t['players']}.id\n             FROM {$t['players']}, {$t['b3_clients']}\n          WHERE {$t['b3_clients']}.id = {$t['players']}.client_id\n              AND (({$t['players']}.kills > {$minkills})\n                  OR ({$t['players']}.rounds > {$minrounds}))\n              AND ({$t['players']}.hide = 0)\n              AND ({$current_time} - {$t['b3_clients']}.time_edit  < {$timelimit})";
if ($exclude_ban) {
    $query2 .= "AND {$t['b3_clients']}.id NOT IN (\n        SELECT distinct(target.id)\n        FROM {$t['b3_penalties']} as penalties, {$t['b3_clients']} as target\n        WHERE (penalties.type = 'Ban' OR penalties.type = 'TempBan')\n        AND inactive = 0\n        AND penalties.client_id = target.id\n        AND ( penalties.time_expire = -1 OR penalties.time_expire > UNIX_TIMESTAMP(NOW()) )\n      )";
}
$query2 .= "     ORDER BY {$t['players']}.skill DESC\n            ) derivated_table\n            where id = {$player_id}";
$result2 = $coddb->sql_query($query2);
$row2 = $coddb->sql_fetchrow($result2);
$coddb->sql_query("ROLLBACK");
if ($player['hide'] == 1) {
    $advertising = 1;
}
if ($advertising != 0) {
    $db->sql_query($sql);
    $nrec = $db->sql_numrows();
    $indirizzi = $db->sql_fetchrowset();
    for ($j = 0; $j < $nrec; $j++) {
        if ($ubicazione) {
            $ubicazione .= " - ";
        }
        $ubicazione = $indirizzi[$j]["via"] . " " . $indirizzi[$j]["civico"];
        if ($indirizzi[$j]["interno"]) {
            $ubicazione .= "/" . $indirizzi[$j]["interno"];
        }
    }
    //Cerco info sulla pratica
    $sql = "select * from pe.avvioproc where pratica={$idpratica}";
    $db->sql_query($sql);
    $dati_pratica = $db->sql_fetchrow();
    $titolo = "Pratica n° " . $dati_pratica["numero"] . " del " . $dati_pratica["data_presentazione"];
    //Scrivo i dati sulla pratica
    print "\n<H2><input type=\"checkbox\" value=\"{$idpratica}\" name=\"idpratica[]\"><a href=\"#\" onclick=\"javascript:NewWindow('praticaweb.php?pratica={$idpratica}','PraticaWeb',0,0,'yes');\">{$titolo}</a></H2>";
    print "\n<input name=\"numero[]\" type=\"hidden\" value=\"" . $dati_pratica["numero"] . "\">";
    print "\n<p>Oggetto:" . $dati_pratica["oggetto"] . "<br>";
    print "\nRichiedenti: {$nomi_richiedenti}<br>";
    print "\nUbicazione: {$ubicazione}";
    print "<img src=\"images/gray_light.gif\" height=\"2\" width=\"90%\">";
    unset($nomi_richiedenti);
    unset($indrizzi);
}
$modo = "view";
if ($totrec === 0) {
    // Ricerca senza risultato
    $azione = "<br>\n\t\t<center><input name=\"azione\" type=\"button\" class=\"hexfield\" tabindex=\"14\" value=\"Indietro\" onclick=\"javascript:document.location='{$active_form}?{$commissione}=1&pratica={$idcomm}&mode=edit&ricerca=0'\"></center>";
Esempio n. 8
0
include( 'mysql4.php' );
include( '../config.php' );

//first we need to retrieve the list of all active companies that might have imported data
$db_support = new sql_db( $supportdb, $dbuser, $dbpasswd, 'nizex_support', false );

if ( $db_support->db_connect_id )
	{
	$query	= "select CompanyID, DBName, DBHost, TableVersion from optUserCompany where Active=1 ";
		
	if ( !( $result = $db_support->sql_query( $query ) ) )
		{	
		$lbl_error = $dblang[ "ErrorInSQL" ]."<br>".$db_support->sql_error();
		}
	
	while ( $row = $db_support->sql_fetchrow( $result ))
		{		
		$db = new sql_db( $dbhost, $dbuser, $dbpasswd, $row[ 'DBName' ], true );

		$query = "select * from conLeadSources where LeadName='Other'";
		if ( !( $result2 = $db->sql_query( $query ) ) )
			echo "Problem with: ".$query;

		if ( $db->sql_numrows( $result2 ) == 0 )
			{
			$query = "insert into conLeadSources values ( null, 'Other', 1 )";
			if ( !( $result2 = $db->sql_query( $query ) ) )
				echo "Problem with: ".$query;
			}
		} //end while looping through companies	 
	}
function getDBHost( $databasename = '' )
{
global $supportdb, $dbuser, $dbpasswd;
$dbsupport = new sql_db( $supportdb, $dbuser, $dbpasswd, 'nizex_support', false, true );

$query	= "select DBHost from optUserCompany where DBName = '".$databasename."'";

if ( !$result = $dbsupport->sql_query( $query ) )
	{
	LogError( 9369, $query ."<br>".$dbsupport->sql_error(), false );
	return false;
	}

$row = $dbsupport->sql_fetchrow( $result );
return $row[ "DBHost" ];
}
Esempio n. 10
0
include_once "login.php";
$db = new sql_db(DB_HOST, DB_USER, DB_PWD, DB_NAME, false);
if (!$db->db_connect_id) {
    die("Impossibile connettersi al database");
}
if (isset($_GET["mapkey"])) {
    $mapkey = explode('@', $_GET["mapkey"]);
}
//print_r ($mapkey);
$tipo = $mapkey[0];
$mappale = $mapkey[1];
$foglio = $mapkey[2];
$sql = "select oid,extent(buffer(the_geom," . BUFFER_SIZE . ")) from map.ct_particelle where foglio ilike('{$foglio}') and mappale ilike ('{$mappale}') group by oid;";
$result = $db->sql_query($sql);
$extent = $db->sql_fetchrow();
$ext = $extent["extent"];
$objid = $extent["oid"];
if ($ext) {
    $p1 = strpos($ext, "(") + 1;
    $p2 = strpos($ext, ")");
    $ext = substr($ext, $p1, $p2 - $p1);
    $ext = str_replace(",", "+", $ext);
    $ext = str_replace(" ", "+", $ext);
    $ext2 = str_replace("+", ";", $ext);
    include "http://localhost/cgi-bin/mapserv.exe?map=C:\\[pmapper]\\projects\\ceriale\\map\\catasto.map&mapext={$ext}";
    ?>
<SCRIPT LANGUAGE="JavaScript1.2">
  function openPmapper(winwidth, winheight, gLanguage, startParameters){
  //CASO FULLSCREEN DA AGGIUNGERE ALLE POSSIBILITA
  //se il browser non riconosce la dimensione della finestra potrei passare un 800x600 
Esempio n. 11
0
 function get_list($idpratica)
 {
     if (isset($_SESSION["MENU_" . $this->tipo . "_{$idpratica}"])) {
         $menu_pratica = $_SESSION["MENU_" . $this->tipo . "_{$idpratica}"];
     } else {
         $db = new sql_db(DB_HOST, DB_USER, DB_PWD, DB_NAME, false);
         if (!$db->db_connect_id) {
             die("Impossibile connettersi al dadabase");
         }
         if ($this->tipo == "commissione") {
             // menu per la commissione
             $menu_settings = @file(MENU . "commissione.mnu");
             foreach ($menu_settings as $riga) {
                 $menu_pratica[] = explode(",", $riga);
             }
             $mnu = "commissione";
         } elseif ($this->tipo == "commissione_paesaggio") {
             // menu per la commissione del paesaggio
             $menu_settings = @file(MENU . "commissione_paesaggio.mnu");
             foreach ($menu_settings as $riga) {
                 $menu_pratica[] = explode(",", $riga);
             }
             $mnu = "commissione_paesaggio";
         } elseif ($this->tipo == "cdu") {
             // menu per la commissione
             $menu_settings = @file(MENU . "cdu.mnu");
             foreach ($menu_settings as $riga) {
                 $menu_pratica[] = explode(",", $riga);
             }
             $mnu = "cdu";
         } elseif ($this->tipo == "condono") {
             $menu_settings = @file(MENU . "condono.mnu");
             foreach ($menu_settings as $riga) {
                 $menu_pratica[] = explode(",", $riga);
             }
             $mnu = "condono";
         } elseif ($this->tipo == "vigilanza") {
             // menu per la commissione
             $menu_settings = @file(MENU . "vigilanza.mnu");
             foreach ($menu_settings as $riga) {
                 $menu_pratica[] = explode(",", $riga);
             }
             $mnu = "vigilanza";
         } elseif ($this->tipo == "ambiente") {
             // menu per l'ambiente
             $menu_settings = @file(MENU . "ambiente.mnu");
             foreach ($menu_settings as $riga) {
                 $menu_pratica[] = explode(",", $riga);
             }
             $mnu = "ambiente";
         } elseif ($this->tipo == "pratica") {
             //menu per le pratiche
             $sql = "select menu_list,menu_file from pe.menu where pratica={$idpratica};";
             $result = $db->sql_query($sql);
             if (!$result) {
                 echo "<p><b>ERRORE:</b><br>Configurazione dei menù errata</p>";
                 exit;
             }
             $row = $db->sql_fetchrow();
             $menu_list = str_replace('#', '', $row["menu_list"]);
             $menu_list = explode(",", $menu_list);
             $menu_file = $row["menu_file"];
             $menu_settings = @file(MENU . "{$menu_file}" . ".mnu");
             if (!$menu_settings) {
                 echo "<p><b>ERRORE:</b><br>File di configurazione dei menù mancante o errato</p>";
                 exit;
             }
             $cont_separatore = 0;
             foreach ($menu_settings as $riga) {
                 $menu = explode(",", $riga);
                 $idmenu = $menu[0];
                 if (count($menu) == 1) {
                     //riga di separazione
                     if ($cont_separatore == 0) {
                         //una sola volta
                         $menu_pratica[] = "separatore";
                         $cont_separatore++;
                     }
                 } elseif (in_array($idmenu, $menu_list)) {
                     $menu_pratica[] = $menu;
                     $cont_separatore = 0;
                 }
             }
             $mnu = "pratica";
         }
         $_SESSION["MENU_" . $this->tipo . "_{$idpratica}"] = $menu_pratica;
     }
     $width = '150px';
     print "<DIV id='nav-buttons' style='font-size:0px;'>";
     foreach ($menu_pratica as $menu) {
         if (is_array($menu)) {
             /*print("<A tabIndex=\"0\" href=\"javascript:pagina('".$menu[2]."',$idpratica)\">".$menu[1]."</A>\n
             		<IMG height=\"1 px\" alt=\"\" src=\"images/white.gif\" width=\"$width\" align=\"bottom\" border=\"0\">");*/
             print "<A tabIndex=\"0\" href=\"javascript:pagina('" . $menu[2] . "',{$idpratica})\">" . $menu[1] . "</A>\n";
         } else {
             print "<IMG style=\"height:1px;width:{$width};border:0px;padding:1px;margin:0px;\" src=\"images/gray_light.gif\">";
         }
     }
     print "\n\t\t</DIV>";
     if ($this->tipo == "pratica" or $this->tipo == "condono" or $this->tipo == "cdu" or $this->tipo = "commissione" or $this->tipo == "ambiente") {
         print "<div style=\"width:160; border-width:1 0 1 0px; border-style:solid; border-color:#336699; padding:2 0 2 0px\">\n\t\t\t<a href=\"javascript:loadintoIframe('myframe','" . $this->path . ".iter.php?pratica={$idpratica}&tipo={$this->tipo}')\" style=\"width:160\" class=\"iter-button\">Iter della pratica</a>\n\t \n              </div>\n\t\t";
     }
 }
Esempio n. 12
0
 $module_name = "";
 require_once NV_ROOTDIR . '/includes/sqldata.php';
 $modules_exit = nv_scandir(NV_ROOTDIR . "/modules", $global_config['check_module']);
 $modules_exit[] = 'global';
 //cai dat du lieu cho  ngon ngu
 $sql_create_table = nv_create_table_sys(NV_LANG_DATA);
 foreach ($sql_create_table as $query) {
     if (!$db->sql_query($query)) {
         $nv_Request->set_Session('maxstep', 1);
         $db_config['error'] = !empty($db->error['user_message']) ? $db->error['user_message'] : $db->error['message'];
         break;
     }
 }
 $sql = "SELECT * FROM `" . $db_config['prefix'] . "_" . NV_LANG_DATA . "_modules` ORDER BY `weight` ASC";
 $result = $db->sql_query($sql);
 while ($row = $db->sql_fetchrow($result)) {
     $setmodule = $row['title'];
     if (in_array($row['module_file'], $modules_exit)) {
         $sm = nv_setup_data_module(NV_LANG_DATA, $setmodule);
         if ($sm != "OK_" . $setmodule) {
             die("error set module: " . $setmodule);
         }
     } else {
         $sql = "DELETE FROM `" . $db_config['prefix'] . "_" . NV_LANG_DATA . "_modules` WHERE `title`=" . $db->dbescape($setmodule);
         $db->sql_query($sql);
     }
 }
 //cai dat du lieu mau
 $filesavedata = NV_LANG_DATA;
 $lang_data = NV_LANG_DATA;
 if (!file_exists(NV_ROOTDIR . "/install/data_" . $lang_data . ".php")) {
Esempio n. 13
0
if (!$db->db_connect_id) {
    die("Impossibile connettersi al database");
}
switch ($_GET["funz"]) {
    case "crea_elenco":
        $obj = $_GET["elenco"];
        $tab = $_GET["tabella"];
        $filtro = $_GET["filtro"];
        $val_filtro = $_GET["val_filtro"];
        $pratica = $_GET["pratica"];
        $oggetto = $_GET["oggetto"];
        /**/
        $sql = "SELECT data_presentazione,destuso1 FROM pe.avvioproc LEFT JOIN pe.progetto ON avvioproc.pratica=progetto.pratica WHERE avvioproc.pratica={$pratica};";
        //if($_SESSION["USER_ID"]<=3) echo "<p>$sql</p>";
        $db->sql_query($sql);
        $ris = $db->sql_fetchrow();
        $data = $ris["data_presentazione"];
        $destuso = $ris["destuso1"];
        $sql = "SELECT tipoxoneri FROM pe.vincoli LEFT JOIN pe.e_vincoli_zone ON vincoli.vincolo=e_vincoli_zone.vincolo AND vincoli.zona=e_vincoli_zone.zona WHERE pratica={$pratica};";
        //if($_SESSION["USER_ID"]<=3) echo "<p>$sql</p>";
        $db->sql_query($sql);
        $ris = $db->sql_fetchlist("tipoxoneri");
        if ($ris) {
            foreach ($ris as $val) {
                $sql = "SELECT DISTINCT opzione FROM oneri.elenco_d2 WHERE zona LIKE '%{$val};%'";
                if ($db->sql_query($sql)) {
                    $opt = $db->sql_fetchrow();
                }
                if ($opt) {
                    break;
                }