do i need to make a mysql_close

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
innosys
Forum Newbie
Posts: 7
Joined: Mon Aug 22, 2005 9:47 am

do i need to make a mysql_close

Post 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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post 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.
innosys
Forum Newbie
Posts: 7
Joined: Mon Aug 22, 2005 9:47 am

Post 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)

------------------------------------------------------
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

should probably get it more RAM...
innosys
Forum Newbie
Posts: 7
Joined: Mon Aug 22, 2005 9:47 am

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

are you using a persistant connection or non-persistant?
innosys
Forum Newbie
Posts: 7
Joined: Mon Aug 22, 2005 9:47 am

Post by innosys »

Well i use persistant connection
Post Reply