xbase Posted February 14, 2007 Share Posted February 14, 2007 here is the connection: /* Database Connection | Pear::DB API --------------------------------------------------------------*/ $dsn = "mysql://$user:$pass@$host/$db_name"; $db = DB::connect($dsn); if (DB::isError($db)) { die ($db->getMessage()); } here is the code: /** * Creates the header for the directory * * @param string $hostname * @param string $view * @param string $i * @return string */ function top_nav($hostname,$view, $i) { $l = chr($i); // Connect to the database so that $s = "SELECT * FROM md_models WHERE alias REGEXP '^($l)'"; $q = $db->query($s); if (DB::isError($result)) { die ($result->getMessage()); } $r = $q->fetchRow(); $v = $db->getOne($s); // Print valid letters if ($v!=0) { $letter = '<td width=20 align=center> <a href="index.CODE?cmd=find&l='.$l.'&view='.$view.'" style="color: black; text-decoration: none; font-weight: bold">'.$l.'</a> </td>'; } else { $letter = '<td width=20 align=center style="color: #CCCCCC; font-weight: bold">'.$l.'</td>'; } return $letter; } This is the error: Fatal error: Call to a member function on a non-object in /data1/members.scoreland/docs/cgi/secured/modeldir/lib/functions/functions.misc_utilities.CODE on line 77 Here is line 77: $q = $db->query($s); Does anyone have any clue what is causing the issue, its starting to annoy me. Link to comment https://forums.phpfreaks.com/topic/38541-peardb-issues/ Share on other sites More sharing options...
btherl Posted February 15, 2007 Share Posted February 15, 2007 It means $db is not an object. Most likely, $db within your function does not refer to the same variable which you used to open the database connection. How to fix it depends on how you've integrated your function and the database connection code. Link to comment https://forums.phpfreaks.com/topic/38541-peardb-issues/#findComment-185093 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.