Web Hosting Talk







View Full Version : Need Urgent Help in MySQL


2cool2
02-24-2002, 12:24 PM
<?php
$maxthreads = 6;
$dbservertype="mysql";
$servername="xxxxxx";
$dbusername="xxxxx";
$dbpassword="xxxxx";
$dbname="xxxxx";
$pwdincp=0;
$technicalemail = "xxx@xxx.com";
$usepconnect = 1;

$db=mysql_connect($servername,$dbusername,$dbpassword);
mysql_select_db($dbname);
$query = "SELECT * FROM thread ORDER BY lastpost DESC LIMIT $maxthreads";
$resultlatest = mysql_query($query,$db);
while ($latest_array = mysql_fetch_array($resultlatest)) {
echo "<b><a target=new href=\"http://www.domain.com/forum/showthread.php?threadid=$latest_array[threadid]\">$latest_array[title]</a><br><br></b>";
}
?>

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

My Question
The script is opening a session with MySQL, Is it closing it?
Yes or No? If No, How to make the script close the session?

Thanks you very much!

jks
02-24-2002, 02:38 PM
Originally posted by 2cool2
<?php
$maxthreads = 6;
$dbservertype="mysql";
$servername="xxxxxx";
$dbusername="xxxxx";
$dbpassword="xxxxx";
$dbname="xxxxx";
$pwdincp=0;
$technicalemail = "xxx@xxx.com";
$usepconnect = 1;

$db=mysql_connect($servername,$dbusername,$dbpassword);
mysql_select_db($dbname);
$query = "SELECT * FROM thread ORDER BY lastpost DESC LIMIT $maxthreads";
$resultlatest = mysql_query($query,$db);
while ($latest_array = mysql_fetch_array($resultlatest)) {
echo "<b><a target=new href=\"http://www.domain.com/forum/showthread.php?threadid=$latest_array[threadid]\">$latest_array[title]</a><br><br></b>";
}
?>

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

My Question
The script is opening a session with MySQL, Is it closing it?
Yes or No? If No, How to make the script close the session?

Thanks you very much!

Yes, it does close the connection.

By the way: Did you include all the code that you have here? - The code above seems quite weird.

I guess you "accidentiallly" left out important bits. Like why does it say "use pconnects" when it actually have no option for doing so.

If you're actually using pconnects (which is not shown above), then no, it does not close the connection.

sjau
02-24-2002, 06:58 PM
isn't mysql connection automatically being closed at the end of the script even if there is a pconnection while normal connection just close after the query has been made!?!

jks
02-24-2002, 07:03 PM
Originally posted by sjau
isn't mysql connection automatically being closed at the end of the script even if there is a pconnection while normal connection just close after the query has been made!?!

No.

mysql_pconnects does not close the connections at the end of the script (but at the end of the slave's lifetime).

Ordinary mysql_connects does close the connection at the end of the script, not after a query has been made.

sjau
02-24-2002, 07:07 PM
I'm never sure what way is right. Thanks for the the clarification!