Curious code behavior inside/outside function
| From: | Karen Resplendo | Date: | Wed, 24 Sep 2003 18:58:07 +0000 |
| Subject: | Curious code behavior inside/outside function | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-30669@lists.php.net to get a copy of this message | ||
I can't get odbc call to work inside of a function. It works on the outside, then I pass the
recordset and fieldname to the function to use the data. I would like to just have the whole odbc
stuff inside the function. Am I missing something obvious? This is the error I get for the odbc_do
line:
"Supplied argument is not a valid ODBC-Link resource"
**************************
This works:
$data=odbc_do($connectionSDWIS,"EXEC sp_PWSExists '$pws'");
if (isValidPWS($data))
{
//do something here
}
else
{
//do something here
}
function isValidPWS($data)
{
$lookforthispws= odbc_result($data,1);
if ($lookforthispws=="YES")
{
return true;
}
}
****************************
This doesn't work:
function isValidPWS($pws)
{
$data=odbc_do($connectionSDWIS,"EXEC sp_PWSExists '$pws'");
$lookforthispws= odbc_result($data,1);
if ($lookforthispws=="YES")
{
return true;
}
}
---------------------------------
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software