PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
If you have code outside a function for example, on the same page, and that function is called, will $variable or and mysql queries be defined universally as a rule throughout multiple functions that use those variables on the same page?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
You need to consider how scope works in PHP - variables declared outside of functions and class methods are in a global scope, variables declared inside functions are in a local scope. The global and local scope are separate except for the use of the global keyword, which allows variables from the global scope to be accessed inside a local scope. That is generally considered bad practice, since scoping is very important for the integrity of variable data and locality of changes - ie, changes you make in one place should not have unforeseen effects on another.