SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Adodb question

  1. #1
    SitePoint Member GIJew's Avatar
    Join Date
    Mar 2004
    Location
    Corona, CA.
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Adodb question

    Hi,

    I decided to FINALLY make the transition to the adodb world because, well, I should have done it in the beginning.

    I have things setup nice and neat, found a few tutorials that showed some nice functionality and what not, blah blah, blah right?

    I setup a test.php and it worked perfectly everytime. When I started to implement it on a single page it stopped working. Must be my paths eh? Perhaps.

    When I do ANYTHING with adodb inside of a homegrown function, adodby cannot be found and i get the Call to a member function on a non-object error.

    To elaborate a bit, if I just throw in:
    PHP Code:
    $results $db->GetAll("SELECT * FROM table"); 
    foreach(
    $results AS $result){ 
       echo 
    $result['column_name']."<br />"

    I see what I should see. If I were to wrap function someFunction() around it, that same query would fail with the above error.

    Since I have absolutely no experience with adodb and I'm completely lost as to why it cannot be found inside of MY functions when every other function works...I come to one of you.

    I'm running:
    PHP 4.4.0
    MySQL 4.1.14
    Smarty 2.6.9
    Adodb 4.65

  2. #2
    SitePoint Wizard
    Join Date
    Jan 2001
    Location
    Grand Rapids, MI
    Posts
    1,284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Because $db was defined outside of the function. In all of your functions that you use $db, put global $db; inside at the top of each function.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •