Hi,

    I'm very new with php, so perhaps it's a silly question.

    I want a connection with a mysql database.
    This works. I can open, retrieve data, and close the database.

    But this happens in the same page.

Now I want one page that has a function who's  opening  and close the
connection.  In another page I want include this page. But I don't know the
syntax.

e.g

page connectie.php

Function openDB()
{
  $link = mysql_connect("localhost", "host", "pas")

        or die("geen connectie mogelijk : " . mysql_error());
    print "connectie ok";
    mysql_select_db("database") or die("geen database gevonden");

}

Function closeDB()
{
          mysql_close($link);
}
End Function
 ?>

<?php

page input.php

include ('connectie.php');

  //open connectie

     $connectie = openDB();

     //code

//close connectie
  $connectie = closeDB();



This gives an error when I want to close the db. In the function I said
close($link) but of course he cann't see this variabel. How can I fix that?

Alain D'Haene

Or is it possible the set the connection in an Object, and use this object
during the Session?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to