Here is code for a php gallery which has stopped working. I wonder if it’s because of upgrades to php on the server, that this code is no longer working? Otherwise nothing else has been changed. Any assistance would be appreciated.
[php]
The Old Mill Farm, Inc., Equestrian Facility, Lexington NC
<?php
global $catstr;
global $catarr;
$db = @mysql_connect('localhost', 'username', 'password');
if (!$db)
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}
// Select the database
if (!@mysql_select_db('database_name')) {
exit('
Unable to locate the images database at this time.
');
}
$catarr = array ("Facility", "Event", "XC", "Jump", "Dressage");
if ($category == '')
{
$category = 0;
}
$catstr = $catarr[$category];
$query = 'SELECT * FROM images WHERE category REGEXP "'.$catstr.'" ORDER BY id';
$result = mysql_query($query);
if (!$result) {
exit('
Error performing query: ' .
mysql_error() . '
');
}
?>
|
<? include ( "topmenu.html" ); ?>
|
<td class="maintexthm" align="center">
<table border="1" cellpadding="5" cellspacing="0" style="border-style:solid; border-collapse: collapse; width:750; text-align:center" bordercolor="#111111" width="100%" id="AutoNumber1">
<?
echo '
';
echo '';
echo 'Choose a category: ';
for ($q=0; $q<5; $q++)
{
echo ''. $catarr[$q] . ' ';
}
echo "";
// This is where I display category name
echo "$catstr";
echo "Click photo and larger view will open in a new window. ";
echo " | ";
echo " ";
create_gallery($result);
?>
</table>
</td>
</tr>
</table>
<? include ( "footer.html" ); ?>
</td>
</tr>
</table>
</center>
</div>
</td>
|
<?
function create_gallery($data)
{
$num_results = mysql_num_rows($data);
echo " ";
$imgindex=0;
$rows=$num_results/4 + 1;
// echo "num results " . $num_results . " rows " . $rows;
$l=0; //0 based array, number of columns in first row.
for ($l=0; $l < $rows ; $l++)
{
echo " |
";
for ($col = 0; $col <4; $col++)
{
if ($imgindex < $num_results) {
$row = mysql_fetch_array($data);
echo '';
echo '';
echo '';
echo ''; //thumbnail
echo ' ';
echo '' . $row['name']. ' ';
echo "
| ";
}
$imgindex++;
}
echo " "; ;
}
}
?>
[/php]
|