Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as PHP by fsdfsdfsd ( 15 years ago )
1.
      function MysqlConnect()
   2.
              {
   3.
                      global $dbcnx;
   4.
                      $dbcnx=@mysql_connect(DB_SERVER, DB_SERVER_USERNAME, DB_SERVER_PASSWORD);
   5.
                      if (!$dbcnx)
   6.
                      {
   7.
                              exit("Соединение с бд не установлено");
   8.
                      }
   9.
                      if (!@mysql_select_db(DB_DATABASE, $dbcnx))
  10.
                      {
  11.
                              exit("Таблица не найдена");
  12.
                      }
  13.
                      db_query('set names utf8');
  14.
                      return $dbcnx;
  15.
              }
  16.
              function db_query($sql)
  17.
              {
  18.
                      global $dbcnx;
  19.
                      $k=0;
  20.
                      while(!@$res=mysql_query($sql))
  21.
                      {
  22.
                              @mysql_close($dbcnx);
  23.
                              MysqlConnect();
  24.
                              if($k>5)
  25.
                              {
  26.
                                      echo mysql_error();
  27.
                              break;
  28.
                              }
  29.
                              $k++;
  30.
                      }
  31.
                      return $res;
  32.
              }

 

Revise this Paste

Your Name: Code Language: