I am using adodb for accessing my records from MYSQL Database.
I define an object of adodb "$db" which is used for executing queries in my configuration file which is accessible in each and every page of the application.
Now when i try to access $db object in a function it says
Expand|Select|Wrap|Line Numbers
- Fatal error: Call to a member function Execute() on a non-object
Here is code of my function.
Function calling
Expand|Select|Wrap|Line Numbers
- <div class="suckerdiv">
- <ul id="suckertree1">
- <?php createMenu(0, $db);?>
- </ul>
- </div>
Expand|Select|Wrap|Line Numbers
- <?php
- function createMenu($parId, &$db){
- $q="select cat_id, parent_id, cat_name from ".CATEGORY." where parent_id='$parId'";
- $rs = $db->Execute($q);
- if($rs->RecordCount()>0){
- while(!$rs->EOF){
- $q="select cat_id, cat_name from ".CATEGORY." where parent_id=".$rs->fields('cat_id')."";
- $rs = $db->Execute($q);
- $noRows=$rs->RecordCount();
- if($noRows > 0){
- ?>
- <li><a href="products/<?php echo $rs->fields('cat_id');?>"><?php echo $rs->fields('cat_name');?></a>
- <ul>
- <?php createMenu($row_cat['cat_id'],$db);?>
- </ul>
- </li>
- <?php }else{?>
- <li><a href="products/<?php echo $rs->fields('cat_id');?>"><?php echo $rs->fields('cat_name');?></a></li><?
- }
- }
- }//end while
- }?>