Calling ADODB inside a function?
Posted
by
David
on Stack Overflow
See other posts from Stack Overflow
or by David
Published on 2011-01-01T13:32:39Z
Indexed on
2011/01/01
13:53 UTC
Read the original article
Hit count: 383
Hi,
I'm wondering why when i put an sql ADODB query in side a function it produces the following error:
Fatal error: Call to a member function Execute() on a non-object in -path to script-
My function is something like:
$dsn = 'mysql://user:pass@localhost/db';
$db = ADONewConnection($dsn);
function getem($q){
$r=$db->Execute($q);
return $r->RecordCount();
}
echo getem("select * from table");
Any ideas how to fix that?
© Stack Overflow or respective owner