Defender your're not quite right , and also
What PHP does is making a copy of the var $query.
Let the function do somthing with $query and return this.
$query does not need to be global, since you are allready passing it to the fuction and thus making a copy of it.
in effect you have to vars called $query (one existing only with in the function)
I wrote my own sql lib using this priciple and it works fine for me. Without global variables.
You should make $query global if you define your funtion like this:
function sql_query()
{
global $query;
$result = mysql_query($query);
$array = mysql_fetch_array($result);
return $array;
}
$query = "SELECT column FROM table";
$resultSet = sql_query($query);
Now $query is a global variable available within the fuction and outside it.
Also note that you cannot do
$resultSet = sql_query("SELECT....");
if you define a function like this
Since there is no $query.
ps:
*nm the ps