Location: PHPKode > projects > VideoSplurge > admin/includes/db.php
<?
function getvar($variable)
{
	$gvsql = "SELECT * FROM variables WHERE variable='$variable'";
	$gvresult = mysql_query($gvsql);
	$gvnumrows = mysql_num_rows($gvresult);
	if($gvnumrows<1) { return -1; }
	$gvrow = mysql_fetch_row($gvresult);
	$gvresult = stripslashes($gvrow[2]);
	return $gvresult;
}

function setvar($svvariable, $svvalue) // check existence, create or update.
{
	$svvalue = mysql_real_escape_string($svvalue);
	
	$svsql = "SELECT value FROM variables WHERE variable='$svvariable'";
	$svresult = mysql_query($svsql);
	if(mysql_num_rows($svresult)<1) {
		//echo "Variable does not exist. Creating...";
		$svsql = "INSERT INTO variables (variable, value) VALUES('$svvariable', '$svvalue')";
		$svresult = mysql_query($svsql);
		if(!$svresult) { echo "Error: " . mysql_error() . "<br />\n"; }
	}
	else {
		//echo "Variable exists, updating...";
		$svsql = "UPDATE variables SET value='$svvalue' WHERE variable='$svvariable'";
		$svresult = mysql_query($svsql);
		if(!$svresult) { echo "Error: " . mysql_error() . "<br />\n"; }
	}
}
?>
Return current item: VideoSplurge