Return value from function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Satterwhite

    Return value from function

    I wanted to centralize connection to a MySQL database, so I created a
    function that reads (eliminating extraneous)

    function connectDB() {
    $db = mysql_connect(-------);
    mysql_select_db ("dbname");
    return $db;
    }

    In my main routine I have

    $db = connectDB();
    ----Database activity------
    mysql_close($db );

    Problem: I get an error message at this point telling me that this isn't a
    valid mysql reference. Why? I'm probably overlooking it, but I don't see a
    limitation on the return value in the documentation.



Working...