I have used a web application that I wrote myself and it has been working great just until a few days ago. I don't know if the web hotel has done anything, but I can't understand what that could be either.
I use a code snippet to create a "sub-page select string" similar to tab-pages or wheatever. this is the function to generate them:
function showpages($arr, $file, $default) {
if ($_GET['page'] == '') {
$page = $default;
} else {
$page = $_GET['page'];
}
foreach ($arr as $key => $value) {
if ($page == $key) {
echo $value;
} else {
echo "<a href='".$file."?page=".$key."'>".$value."</a>";
}
echo " ";
}
echo "<br><br>";
}
I use this function by sending in an named array with pagename->title
which php-page i am currently in and a default page if none selected.
$page['pop'] = 'Befolkning'; $page['troop'] = 'Trupper'; $page['build'] = 'Byggnader'; showpages($page, 'profile.php', 'pop');
which outputs the array parts in a row, with links on everyone but the one choosen.
Now to the new found problem, which has not occured before.
when a page is choosen, i.e. when the line has its "?page=xxxxx" part,
I get a warning:
Warning: Invalid argument supplied for foreach()
But the warning ONLY occurs when a page is choosen. if there is no choosen page, it works as it always did before.
anyone got any ideas? do you understand the problem?
accesses with no page-parameter works,
accesses with page-parameter does no longer work, but generates an warning as above. worked fine until now.
absolute no modifications has been made to the code for months and this just happened a few days ago....
thanks in advance
Örjan


Sign In
Create Account

Back to top










