Page 1 of 1

small function

Posted: Thu Aug 31, 2006 3:38 am
by rsmarsha
I wrote a small function for queries:

Code: Select all

function db_query($sql, $name)
{
	$string = $sql;
	global $query;
	$query = mysql_query($string) or die("Query($name): $string Failed".mysql_error());
}
How would i change that so that the last line would change depending on what $name was?

So if name was test it would be

Code: Select all

$test = mysql_query($string) or die("Query($name): $string Failed".mysql_error());

Posted: Thu Aug 31, 2006 5:27 am
by onion2k
Don't use global variables like that. It's asking for trouble.