Include the file you would like the variable to be accessible within, like so
include('somefile.php')
and at the top of that file you might need put something like [depending on server configurations]
global $pubname
But in most cases you would not need to do this.
In regards to security, depending on how $pubname
is set, your query may or may not be prone to sql injection.
Note: There are other means to include()
files such as include_once()
, require()
and require_once()
, from php.net:
The documentation below also applies
to require(). The two constructs are
identical in every way except how they
handle failure. include() produces a
Warning while require() results in a
Fatal Error. In other words, use
require() if you want a missing file
to halt processing of the page.
include() does not behave this way,
the script will continue regardless.
Be sure to have an appropriate
include_path setting as well. Be
warned that parse error in required
file doesn't cause processing halting
in PHP versions prior to PHP 4.3.5.
Since this version, it does.