Apart from whatever "not working" might be, you seem to have several missconceptions about different things.
# Here you define the variable, and initialize it to a non-empty value
# Do note the difference between 'null' (non-empty, 4 character string) and
# null (empty, the null-value)
$var = 'null';
# Which means that this is NEVER true
if (empty($var))
{
# This sentence covers all cases by simply using the word "empty",
# but since you also include 0 as a possibility, which is only one of the
# many meanins of "empty", the sentence is rather confusing.
# Stick to empty, or list all possibilities:
# 0.0, 0, '0', , '', false, array(), null
# But do note that '0.0' is NOT empty, just like 'null' isn't.
echo '$var is either 0, empty, or not set at all';
}
# While this is ALWAYS true.
# This statement is also not at all related to the previous statement, just
# like $i = 4; has absolutely no relation to $j = 'animal';
# If you want there to be any kind of relationship between these two statements,
# you would need to use:
# elseif
# which still wouldn't give it the meaning of your english sentence below. It would
# become "$var is set, even though it is NOT empty"
if (isset($var))
{
# Which means that the meaning of this sentence is ALWAYS false:
# $var is after all NOT empty.
echo '$var is set even though it is empty';
}
# And this function makes little sense if you pass in values that are stored
# as non-strings in the database, such as int and float. It also makes little sense
# to have one function for each specific case of data type used rather than handle all
# types in the same place.
# Or better yet, use prepared statements and have it done for you.
function PrepSQL($value)
{
$value = "'" . mysql_real_escape_string($value) . "'";
# return is not a function, it's a languge construct, and the manual
# lists _several_ good reasons for NOT using it as a function
return($value);
}