Page 1 of 1

Help Needed With This Error. New to PHP PLEASE HELP

Posted: Tue Feb 19, 2008 8:00 pm
by grabber
Hi

I am getting the following error warnings from this script, I tried all most various things that i know (not many) but could not figure this out...can any one help me out please...

First the Error messages then i'll paste the code below right after!

ERROR MESSAGE:

Warning: file() expects parameter 2 to be long, string given in /home/someuser/public_html/mysite/manage/template.php on line 35

Warning: implode() [function.implode]: Bad arguments. in /home/someuser/public_html/mysite/manage/template.php on line 35

THIS IS THE SCRIPT (i've colored the line)

<?php

//=====================================
//
//=====================================
// Filename : template.php
// Path : Manage directory
// last update : 2002/03/13
// Desc : Edit template
//=====================================


//=====================================
// File include part & DB Layer
//=====================================

include ("./authen.php");
include ("../function/main_func.php");
include ("../$Slang/m_common.php");

//=====================================
// Prepare progrom
//=====================================

isset($_POST) ? extract($_POST) : extract($HTTP_POST_VARS) ;

//=====================================
// View template select form parts
//=====================================


if (!$switch) {


if ($fname) $content = implode("",file("../$Stemplate/$fname",r));

$content = htmlspecialchars($content);


//===========================
// Read Filelist
//===========================

$handle=opendir("../$Stemplate");
while ($file = readdir($handle)) {
if (is_file("../$Stemplate/$file")) {
if ($fname == $file)
$file_list .= "<option selected>$file</option>\n";
else
$file_list .= "<option>$file</option>\n";
}
}
closedir($handle);


//=====================================
// Print form
//=====================================

print <<<EOF
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=$Scharset'>
<LINK rel='stylesheet' type='text/css' href='./linker.css'>
</head>
<body bgcolor="#E9E9E9" text='black' link='blue' vlink='purple' alink='red'>
<form action="template.php" method=post>

<table border=0 cellpadding=0 cellspacing=1>
<tr>
<td>

<table width="100%" border="1"><tr><td bgcolor="#000066" align="center">
<b><font color="white" size="2">$l_edit_tem</font></b>
</td></tr></table>

</td> </tr>

<tr><td width=500>&nbsp;</td></tr>

<tr>
<td bgcolor='#E0E0E0' align=right><font size=2><select name="fname">
<option value='' selected>$l_sel_file1</option>
$file_list </select></font><input type='submit' value='$l_sel_file2' class=cinput></td>
</tr>

<tr>
</form><form action='template.php' method='post'>
<td align='center' height='24' bgcolor='#E0E0E0'>
<font size='2'>
<textarea rows='20' cols='50' name='content' style='width:500px'>$content</textarea><br>
<input type='hidden' name='file_name' value='$fname'>
<input type='hidden' name='switch' value='edit'>

<input type='submit' value='$l_edit_tem' class=cinput>
</font>
</td></form>
</tr>
</table>
</body>

EOF;
exit;

}

//=====================================
// Edit and Print template result
//=====================================

elseif ($switch=="edit") {

if (!$content) errmsg($l_error_notem);
if (!$file_name) errmsg($l_error_nofname);


$content = stripslashes(trim($content));
$fd = fopen("../$Stemplate/$file_name",w);
fputs($fd,$content);

print <<<EOF
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=$Scharset'>
<LINK rel='stylesheet' type='text/css' href='./linker.css'>
</head>

<body bgcolor="#E9E9E9">
<table width="500" border="1"><tr><td bgcolor="#000066" align="center">
<b><font color="white" size="2">$file_name $l_tem_result</font></b>
</td></tr></table>

</body></html>
EOF;

}
?>
Can you please assist me...Many thanks in advance.

Regards
Grabber

Re: Help Needed With This Error. New to PHP PLEASE HELP

Posted: Tue Feb 19, 2008 10:13 pm
by webspider

Code: Select all

 
if ($fname) $content = implode("",file("../$Stemplate/$fname",r));
 
replace with

Code: Select all

 
if ($fname) $content = implode("",file("../$Stemplate/$fname"));