I am having a problem with a script. First, it worked fine. Then as the site progressed and I added more code to it the script stopped working.
<?php
//simple blocks: output activated block modules
if ($session->logged_in) {
if ($session->isAdmin()) {
$query = "SELECT `id`, `name`, `location`, `position`, `status` FROM `modules` WHERE position='left' and status='on' ORDER BY `id` ASC LIMIT 20";
$result = mysql_query($query) or die(mysql_error());
}
else {
$query = "SELECT `id`, `name`, `location`, `position`, `status`, `admin_req` FROM `modules` WHERE position='left' and status='on' and admin_req='no' ORDER BY `id` ASC LIMIT 20";
$result = mysql_query($query) or die(mysql_error());
}
}
if (mysql_num_rows($result) == 0) {
echo '<div class="borderBlock"><div class="textBlock"><center>'.$row['name'].'<br>';
echo 'No blocks activated!';
echo '</div></div><br></center>';
}
if ($page == "Administration") {
while($row = mysql_fetch_assoc($result)) {
echo '<div class="borderBlock"><div class="textBlock"> <center>'.$row['name'].'<br>';
include('../'.$row['location'].'');
echo '</div></div><br></center>';
}
}
else{
while($row = mysql_fetch_assoc($result)) {
echo '<div class="borderBlock"><div class="textBlock"> <center>'.$row['name'].'<br>';
include(''.$row['location'].'');
echo '</div></div><br></center>';
}
}
?>
Basically, what the script is supposed to do is pull data from a MySQL database and then parse it to produce a block, which calls certain modules. If the user is a guest it will just populate the active modules that don't require administration. If an admin is active it will populate the normal modules and also populate the administration modules, too.
For some unknown reason this has stopped working and I can't seem to figure out why.
Its probably something so easy that I cannot see it and will kick myself later.
If this is bad practice I will consider suggestions for remodeling of the code.