[PHP-DB] Database Connections

2002-11-29 Thread Bill Arbuckle, Jr.
I have a general question concerning databases in php.  More specifically,
what is the general consensus on maintaining a connection.  Some of this is
more than likely my ignorance.

My connection stuff goes something like this ...


$db = mysql_connect(localhost, stuff, pw) or die(Could Not Connect);
mysql_select_db(stuff,$db) or die(Could Not Select Database);

 Other Code Here 

mysql_free_result($result);
mysql_close($db);


It seems very inefficient to open and close a database with each different
page or call to that database.  My question is ... Is there a better way
and, if so, what is it?  I guess I do not quite understand just how long a
connection is maintained.  I hate to write code that doesn't clean up after
itself.  Any suggestions are appreciate.  TIA

Bill


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




[PHP-DB] mysql problem

2002-11-28 Thread Bill Arbuckle, Jr.
Hello all!  I am new to php and I am trying to update a mySQL table using
php v4.2.3 for Windows.  I am using the command:

mysql_query(insert into tblquotehits
(qoption,referer,browser,remoteaddr,dt) values
($quotetype,$referer,$browser,$remoteaddress,$currentdtstring),$db);

I have read the documentation and found some notes on the topic but none
seemed to solve my problem.  I have tried other variations of the command
such as inserting a semicolon at the end of the insert statement before the
closing double quotes.  All variables are defined and all columns are
actually columns in the table ... I have checked all of this.  I have also
returned the result to a variable and echoed it to the screen ... the result
printed is Resource id #2.

This is driving me crazy as I know it must be something quite simple that I
am overlooking.  Any help is greatly appreciated!  TIA

Bill


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