PHP - Taking Include File Location from DB - Fails?

  • Thread starter Thread starter allin4466
  • Start date Start date
A

allin4466

Guest
Ok, so I am trying to make it so I can add blocks to my pages, and just update a "blocks" table that shows what blocks to show on what pages.. I am trying this, but the include function fails for whatever reason. I only have two blocks in the table right now, it displays the first block fine, then just quits. If i replace the include with echo "test test test" both blocks will show.

Code:

mysql_select_db("$db", $con);
$result = mysql_query("SELECT * FROM blocks where page = '$page'");
while($row = mysql_fetch_array($result))
{


echo "<tr><td class='left_nav_header'>".$row['desc']."</td></tr>"; //header
echo "<tr class='left_nav_content_row'><td class='left_nav_content'>";
$x = $row['location']; // gets block page location
$incfile = "../Blocks/$x"; // declares it as Blocks/location/file.php";
include("$incfile");
echo "</td></tr><tr><td class='left_nav_footer'></td></tr>"; //footer
echo "<tr class= 'spacer'><td>Â*</td></tr>";
}
 
Change to include() to a require(). Provided that you have error reporting turned on, it should give you an error message if it's not working (it should only be generating a warning now, which you might or might not see depending on your settings). Even odds it's a minor file name mixup or something on that order.
 
Back
Top