Page 1 of 1

do i need to make a mysql_close

Posted: Mon Aug 22, 2005 10:16 am
by innosys
hi

when i need to get information from the mysql server i use this code

Code: Select all

$hostname = "localhost";
$database = "mydatabse";
$username = "root";
$password = "root";
$mysqlconnect = mysql_connect($hostname, $username, $password) or die(mysql_error());

mysql_select_db($database, $mysqlconnect );
$query_flists1 = "SELECT * FROM mytable WHERE sy_bab = '1' ORDER BY sy_publish DESC, sy_seq Desc LIMIT 0,6";
$flists1 = mysql_query($query_flists1, $mysqlconnect ) or die(mysql_error());
$row_flists1 = mysql_fetch_assoc($flists1);
$totalRows_flists1 = mysql_num_rows($flists1);
< display the result >

mysql_free_result($flists1);
do i have to make mysql_close($mysqlconnect)

and if i have use pconnect insted of connect to i have also to use
mysql_close($mysqlconnect)


and i don;t use the close
what will happend with a 500 000 hit per day


feyd | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Mon Aug 22, 2005 10:22 am
by feyd
pconnect will help a little bit with time requirements, optimizing your queries and tables for speed of execution will help a lot. Minimizing redundant searches/infomation in a retrieval helps a lot in keeping memory requirements down. Once you get that may hits, you may need a newer server anyways..

Posted: Mon Aug 22, 2005 10:38 am
by nielsene
mysql_close isn't generally needed. It happens automatically at the end of your script. However if you have a lot of script running after the last use of the database and returned records sets, it can be good to close the connection manually. Its not something I would worry about until you stat seeing "too many conenction" type error messages though.

Posted: Mon Aug 22, 2005 4:04 pm
by innosys
well i have a dedicated server 2.4 full cash
hard disk 80 GB

Processor #1 Vendor: GenuineIntel
Processor #1 Name: Intel(R) Pentium(R) 4 CPU 2.40GHz
Processor #1 speed: 2393.283 MHz
Processor #1 cache size: 1024 KB

Memory: 513788k/523136k available (1804k kernel code, 8960k reserved, 353k data, 312k init, 0k highmem)

------------------------------------------------------

Posted: Mon Aug 22, 2005 4:49 pm
by feyd
should probably get it more RAM...

Posted: Tue Aug 23, 2005 7:13 pm
by innosys
i change my web site to make close every connect i use but a message appear when i use Mysql_Close

Warning: mysql_close(): 47 is not a valid MySQL-Link resource in /home/syrianew/public_html/new/readnews.php on line 507

Posted: Tue Aug 23, 2005 7:24 pm
by John Cartwright
are you using a persistant connection or non-persistant?

Posted: Wed Aug 24, 2005 2:36 pm
by innosys
Well i use persistant connection