Re: problems with functions/included files/mysql resource

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
> 
> In the function to connect to and select the database, I make the mysql-link 
> resource a global value.

It sounds like you've misunderstood 'global' variable.  The global
statement needs to go inside the function where you want to use the
variable, not where you assign it.  This tells that function to access
that variable from the global scope.  You will need to have this
variable available at the global scope.  Creating it inside another
function will not do, you must return that from the function to the
global scope too

e.g.

<?php

  $db = new mysql;

 ... some code ...


function UseDb()
{
    global $db;

    ... some more code ...
}

?>

Niel

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux