<?php
/*
* buzzword
* Copyright (c) 2003 Jon Tai
*
* $Id: database.inc 267 2004-03-31 03:14:55Z bradt $
*
* This file is part of buzzword.
*
* buzzword is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* buzzword is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with buzzword; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
mysql_connect(DB_HOST, DB_USER, DB_PASS)
or display_error('mysql_connect('.DB_HOST.', '.DB_USER.', ********) failed, exiting');
mysql_select_db(DB_NAME)
or display_error('mysql_select_db('.DB_NAME.') failed, exiting');
// create a random, unique key for a table
function mysql_unique_key($table, $column) {
do {
$key = mt_rand(1, 2147483647);
$sql = "SELECT $column FROM $table ";
$sql .= "WHERE $column = $key";
$result = mysql_query($sql);
} while (mysql_num_rows($result));
return $key;
}
// make a string safe for use in a mysql query
function mysql_quote_string($string) {
return "'".mysql_escape_string($string)."'";
}
?>