can anyone spot the error please?
Posted: Tue Jul 08, 2003 7:01 am
Can anyone spot my error
please - ( this is a message board script )
I get this error
Warning: Invalid argument supplied for foreach() in /home/.sites/14/site467/web/new/treeit.php on line 165
Code: Select all
<script language="JavaScript">
function popUp(URL) {
day = new Date();
id = day.getTime();
<? echo " eval("page" + id + " = window.open(URL, '" + id + "',
'toolbar=$p_toolbar,scrollbars=$p_scrollbars,location=$p_location,statusbar=$p_statusbar,
menubar=$p_menubar,resizable=$p_resizable,width=$p_width,height=$p_height');");";
?>
}
</script>
<title><? echo $title ?></title>
<table class="table" width="<? echo $set_width ?>" border="<? echo $t_border ?>"
cellspacing="<? echo $t_cellspacing ?>" cellpadding="<? echo $t_cellpadding ?>"
bgcolor="<? echo $t_bg ?>">
<?
if($page <= 0)
{
$page = 1;
}
$data = file('/' . $new_file);
$data = array_reverse($data);
$st = file($icons . "/" . $style . "");
foreach($st as $ele) {
$ele = trim($ele);
$icon = explode("|", $ele);
$data = str_replace($icon[0] , "<img src="$icons/$style/" .$icon[1] . "">",$data);
}
$data = str_replace("[url=" , "<a href='",$data);
$data = str_replace("]" , "'>",$data);
$data = str_replace("[/url]" , "</a>",$data);
$data = str_replace("[s]" , "<s>",$data);
$data = str_replace("[/s]" , "</s>",$data);
$data = str_replace("[i]" , "<i>",$data);
$data = str_replace("[/i]" , "</i>",$data);
$data = str_replace("[b]" , "<b>",$data);
$data = str_replace("[/b]" , "</b>",$data);
$display = $number;
$start = ($page * $display) - $display;
$data = array_slice($data, $start, $display);
foreach($data as $element) {
$element = trim($element);
$pieces = explode("|", $element);
include "data/themes/" . $theme . "/table.txt";
}
?>
</table>
</div>
</font>
</div>
<div class="main_col_B">
<font class="wwi">
<div align="left">
<?
if ($id != "write") {
$file = "http://www.distortedmedia.co.uk/data/users.php";
$lines = file($new_file);
foreach($lines as $line)
{
$user = explode("|", $line);
if ($user[0] == $_REQUEST["username"] AND $user[1] == $_REQUEST["password"]) {
break;
} else {
$user = "";
}
}
if ($user == "") {
?>
<FORM ACTION="<?=$PHP_SELF?>?id=write" METHOD="post">
<input type="hidden" name="name" value="Guest" class="form">
<input type="hidden" name="site" value="NONE" class="form">
<input type="hidden" name="url" value="NONE" class="form">
Post message below.<br>
for full member benefits <a class="link3" href="signup.php"><b>sign-up</b></a>
<br>
member <a class="link3" href="member_login.php"><b>log-in</b></a>
<br>
<textarea wrap=virtual name="new_subject" cols="35" rows="15" value="new_subject"
class="form"></textarea><br>
<textarea wrap=virtual name="trial_message" cols="35" rows="15" value="trial_message"
class="form"></textarea>
<div align="center">
<input type="submit" class="button" value="post">
<?
} else {
?>
<FORM ACTION="<?=$PHP_SELF?>?id=write&username=<? echo $username
?>&password=<? echo $password ?>" METHOD="post">
<a class="link3" href="javascript:popUp('tree_view.php')"><b>Show All</b></a><br>
<input type="hidden" name="name" value="<? echo $user[0] ?>"><b>Welcome <? echo
$user[0] ?></b><br>
<input type="hidden" name="site" value="<? echo $user[4] ?>">
<input type="hidden" name="url" value="<? echo $user[5] ?>">
<input type="hidden" name="sn" value="<? echo $user[6] ?>">
<input type="hidden" name="mail" value="<? echo $user[7] ?>">
<textarea wrap=virtual name="new_subject" cols="35" rows="15" value="new_subject"
class="form"></textarea>
<textarea wrap="virtual" name="trial_message" cols="35" rows="15" value="trial_message"
class="form"></textarea>
<br>
<input type="submit" value="¬ post"class="button">
</div>
</div>
<?
}
}
if ($id == "write") {
if(strstr($HTTP_POST_VARS['name'],"|")) {
echo "Name cannot contain the pipe symbol - |";
exit;
}
if(strstr($HTTP_POST_VARS['gender'],"|")) {
echo "Name cannot contain the pipe symbol - |";
exit;
}
if(strstr($HTTP_POST_VARS['site'],"|")) {
echo "Name cannot contain the pipe symbol - |";
exit;
}
if(strstr($HTTP_POST_VARS['url'],"|")) {
echo "Name cannot contain the pipe symbol - |";
exit;
}
if(strstr($HTTP_POST_VARS['sn'],"|")) {
echo "Name cannot contain the pipe symbol - |";
exit;
}
if(strstr($HTTP_POST_VARS['male'],"|")) {
echo "Name cannot contain the pipe symbol - |";
exit;
}
if(strstr($HTTP_POST_VARS['message'],"|")) {
echo "Name cannot contain the pipe symbol - |";
exit;
}
$cread = file('/' . $new_file);
$count = count($cread);
$file = fopen('' . $new_file,"a+");
$date = date("d.M.Y g:i a");
fwrite($new_file,"$name|$gender|$site|$url|$sn|$mail|$new_subject|$trial_message|$date|$
count\r\n");
fclose($new_file);
echo "Added Successfully.";
echo "<br>";
?>
<br>
<div align="center">
Return to <a class="link3" href="<?=$PHP_SELF?>?username=<? echo $username
?>&password=<? echo $password ?>"><b>message board</b>?</a>
</div>
<?
}if ($id == "icons") {
echo "<div align=center><br>";
$st = file($icons . "/" . $style . "");
foreach($st as $ele) {
$ele = trim($ele);
$icon = explode("|", $ele);
echo "<a href="javascript:void(0)"
onClick="document.forms[0].elements[6].value+='$icon[0]';return false;"><img
src="$icons/$style/$icon[1]" border="0"></a>";
}
echo "</div>";
}
?>Warning: Invalid argument supplied for foreach() in /home/.sites/14/site467/web/new/treeit.php on line 165