Re: Function misfunction - 2
| From: | Martin S | Date: | Tue, 31 Dec 2002 12:48:04 +0000 |
| Subject: | Re: Function misfunction - 2 | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-129766@lists.php.net to get a copy of this message | ||
Jason Wong wrote:
> On Tuesday 31 December 2002 20:02, Martin S wrote:
>> Marek Kilimajer wrote:
>> > You forgot global $adb; at the beginning of your function, or use
>> >
>> > $sth = $GLOBALS['adb']->prepare($query);
>>
>> Nope sorry, I've just edited it from my post here. It is in the function.
>
> Hmm, whenever you post code to the list you should *always* (where
> possible) copy and paste. If the code that you post is different to that
> which you are actually running then it makes it difficult for people to
> help you.
>
> So if you can, could you please post your complete unadulterated code?
>
This is the function which should return e.g. "printers" for $lookuptable.
But doesn't.
function setCurrentDevGroup($devID)
{
global $adb;
$query = "SELECT dev_group FROM tracking WHERE (computer = $devID)";
$sth = $adb->prepare($query);
if($sth)
{
$res = $sth->execute();
$resulttable = $sth->fetchrow_hash();
$lookuptable = $resulttable["dev_group"];
// DEBUG
echo $lookuptable; // this give the correct value
}
return $lookuptable;
}