Cannot find the database '$db_name'. Please make sure you have specified a valid MySQL
server hostname in 'include/config.php'.");
return(0);
}
}else{
die("
Cannot connect to MySQL server on '$host'. Please make sure you have specified a valid MySQL
database name in 'include/config.php'.");
return(0);
}
}
function db_execute($sql) {
global $cnn_id;
if (!$cnn_id) { db_connect(); }
$query = mysql_query($sql);
if ($query) {
return(1);
}else{
return(0);
}
}
function db_fetch_cell($sql,$col_name = '') {
global $cnn_id;
if (!$cnn_id) { db_connect(); }
$row = array();
$query = mysql_query($sql);
if ($query) {
$rows = mysql_numrows($query);
if ($rows > 0) {
if ($col_name != '') {
$row = mysql_fetch_assoc($query);
return($row[$col_name]);
}else{
return(mysql_result($query,0,0));
}
}
}
}
function db_fetch_row($sql) {
global $cnn_id;
if (!$cnn_id) { db_connect(); }
$row = array();
$query = mysql_query($sql);
if ($query) {
$rows = mysql_numrows($query);
if ($rows > 0) {
return(mysql_fetch_assoc($query));
}
}
}
function db_fetch_assoc($sql) {
global $cnn_id;
if (!$cnn_id) { db_connect(); }
$data = array();
$query = mysql_query($sql);
if ($query) {
$rows = mysql_numrows($query);
if ($rows > 0) {
while($row = mysql_fetch_assoc($query)) {
$data{sizeof($data)} = $row;
}
return($data);
}
}
}
function array_to_sql_or($array, $sql_column) {
/* if the last item is null; pop it off */
if (empty($array{count($array)-1})) {
array_pop($array);
}
if (count($array) > 0) {
$sql_or = "(";
for ($i=0;($i";
if (!db_execute($sql_save)) { return 0; }
/* get the last AUTO_ID and return it */
if (db_fetch_cell("select LAST_INSERT_ID()") == "0") {
if (isset($array_items["id"])) {
return $array_items["id"];
}else{
return 1;
}
}else{
return db_fetch_cell("select LAST_INSERT_ID()");
}
}
?>