Problem closing mysql connection (Solved)
Posted: Wed Sep 05, 2007 9:41 am
Hi,
In one of my User Defined Tags I'm trying to include an external database query in order to produce a listing.
It looks like:
This lists everything I need however something goes wrong at the footer of the page. This shows:
string(61) "Smarty error: unable to read resource: "globalcontent:footer"" string(61) "Smarty error: unable to read resource: "globalcontent:footer""
and shows no proper footer.
Just removing the last line of the User Defined Tag seems to solve the problem. In my opinion however I need to close the connection to comply with the recommended mysql code. Renaming the link didn't make any difference.
In one of my User Defined Tags I'm trying to include an external database query in order to produce a listing.
It looks like:
Code: Select all
//User Defined Tag: Listing
require ('connection.php');
$link= mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$db = mysql_select_db($database,$link)
or die ("Couldn't select database");
$query = "SELECT * FROM tbl_x LEFT JOIN tbl_y
ON a=b
ORDER BY c, d";
$result = mysql_query($query)
or die ("Couldn't execute query.");
while ($row = mysql_fetch_array($result))
{
echo "<ul>";
extract($row);
echo "
<li>
<a href='http://domain.com/blahblah.php
?page=e&f=$g'>
$c, $d </a>
</li>
</p>";
echo "</ul>";
}
mysql_close($link);string(61) "Smarty error: unable to read resource: "globalcontent:footer"" string(61) "Smarty error: unable to read resource: "globalcontent:footer""
and shows no proper footer.
Just removing the last line of the User Defined Tag
Code: Select all
mysql_close($link);