kmark Posted June 17, 2008 Share Posted June 17, 2008 i am using adodb and am receiving the following error message Fatal error: Call to a member function on a non-object in e:\web\public_html\****\manager.php on line 59 the object is being used in a function - does that matter? Code is below <? include("../adodb/adodb.inc.php"); $db =& ADONewConnection('odbc_mssql'); $dsn = "Driver={SQL Server};Server=myserver;Database=mydb;"; $db->Connect($dsn,'useruser','password'); //URL Variable Validation Not posted //Generate Table function function managerTable($table, $order, $type, $extra=FALSE){ $extrax = (empty($extra)) ? $type : $extra; print '<table><tr><td colspan="3" align="right"><a href="'.strtolower($extrax).'Action.php">Add A '.$type.'</a></td></tr>'; $table .= (empty($order)) ? '' : ' ORDER BY userAdded'; $sql = "SELECT * FROM $table"; $result = $db->Execute($sql); if($result->RecordCount() == 0){ print '<tr><td>No Data</td></tr>'; }else{ while(!$result->EOF){ print '<tr><td>'.$result->fields[1].'</td><td><a href="'.strtolower($extrax).'Action.php?id='.$result->fields[0].'">Edit</a></td><td><a href="'.strtolower($extrax).'Action.php?id='.$result->fields[0].'&action=1" onclick="return confirm(\'Are you sure you want to delete this '.$type.'?\');">Delete</a></td></tr>'; } } print '</table>'; } require_once('inc/header.php'); managerTable($paramA,$paramB,$paramC,$paramD); require_once('inc/footer.php'); Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted June 17, 2008 Share Posted June 17, 2008 $db is not accessible from inside the function...scope's a PITA : ) http://www.php.net/language.variables.scope Quote Link to comment Share on other sites More sharing options...
kmark Posted June 18, 2008 Author Share Posted June 18, 2008 thanks i changed the variable scope and it works fine global $db; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.