So, I want to put this in an include file:
$user = "*****";
$pass = "*****";
$database = "counterpoint";
$link = mysql_connect( "localhost", $user, $pass );
if ( ! $link ) {
$dberror = "Couldn't connect to MySQL server.";
return false;
}
if ( ! mysql_select_db( $database, $link ) ) {
$dberror = mysql_error();
return false;
}
So I don't have to repeat it 8000 times in my site. Then, do I just put the msql_close() on the page that calls this? Like this:
$data = mysql_query( "SELECT reportid, reportname, filename FROM reclamation WHERE clientid=$id" .$orderQuery. " " .$way );
//$num_rows = mysql_num_rows( $data );
while ( $a_row = mysql_fetch_array( $data ) ) {
print "<tr class=\"listContent\">\n";
print "<td valign=\"top\">".$a_row['reportname']."</td>\n";
print "<td valign=\"top\"><a href=\"../uploads/".$a_row['filename']."\" target=\"_blank\">".$a_row['filename']."</a></td>\n";
print "<td align=\"center\"><a href=\"editReport.php?reportid=".urlencode( $a_row['reportid'] )."\">
<img src=\"../edit.gif\" width=\"16\" height=\"14\" border=\"0\"></a></td>";
print "<td align=\"center\"><a href=\"deleteReportAction.php?reportid=".urlencode( $a_row['reportid'] )."\">
<img src=\"../delete.gif\" onclick=\"return checker()\" width=\"14\" height=\"13\" border=\"0\"></a></td>";
}
mysql_close ( $link );
Or do I put it in the function being included? Or am I going about this completely wrong?