", htmlspecialchars($str)); } function query_str_replace ($str, $from, $to) { $a = explode ('&', $str); for ($i = 0; $i < count ($a); $i++) if (strcmp ($a [$i], $from) == 0) $a [$i] = $to; delnull ($a); return implode ('&', $a); } function query_str_add ($str, $what) { $a = explode ('&', $str); for ($i = 0; $i < count ($a); $i++) if (strcmp ($a [$i], $what) == 0) break; if ($i >= count($a)) $a [count($a)] = $what; delnull ($a); return implode ('&', $a); } function mysql_start () { global $cfgLastErr, $link, $dbhost, $dbuser, $dbpwd, $db; if ($link) // уже соединено return true; // Соединяемся с MySQL $link = mysql_connect ($dbhost, $dbuser, $dbpwd); if (!$link) { $cfgLastErr = 'Could not connect to the database: ' . mysql_errno() . ": " . mysql_error(); return false; } mysql_select_db($db); // даже если её нет - всё равно скажем что всё ок. init создаст return true; } function mysql_finish () { global $result, $link; // Очищаем MySQL-соединение @mysql_free_result($result); if (isset ($link) && $link !== false) mysql_close($link); $link = false; } ?>