PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
learning_php_mysql
Forum Commoner
Posts: 27 Joined: Sun Aug 04, 2002 12:58 pm
Location: WA
Post
by learning_php_mysql » Wed Aug 07, 2002 11:26 am
this is suppost to read news files(or create them if they dont exist) and read them into the main file using <iframe> for some reason its not working. you can see the errors it's giving me here
http://r85anderson.coolfreepages.com/home.php any ideas of how to fix it? thanks.
Code: Select all
function shout_box() {
echo("\t<td valign=top><table width=550 cellspacing=0 cellpadding=0 border=0 align=center>");
echo("\n\t\t<tr>\n\t\t\t<td align=right><table width=100% cellspacing=0 cellpadding=0 border=0 valign=top align=center>");
echo("\n\t\t<tr>\n\t\t\t<td height=15></td>\n\t\t\t</tr>");
echo("\n\t\t<tr>\n\t\t\t<td><table width=95% cellspacing=0 cellpadding=0 border=0 valign=top align=center>\n\t\t\t</tr>");
$result=mysql_query("SELECT * FROM shout_box");
for($i=0; $i<mysql_num_rows($result); $i++) {
$get=mysql_fetch_array($result);
$pfile="http://".variables2(subdomain).variables2(domain)."/newsdir/".$i.".php";
if(is_file($pfile)) {
fopen($pfile, "r");
echo("<iframe src="".$pfile." frameborder=0 scrolling=auto height=80 width=500></iframe>");
fclose($pfile);
}
else {
fopen($pfile, "w+");
fwrite($pfile, "<table width=100% bgcolor=003333 cellspacing=0 cellpadding=0 border=0>\n\t<tr>\n\t\t<td>".$getї'headline']."</td></tr>");
fwrite($pfile, "<tr><td align=right>".$getї'post']."</td></tr>");
fwrite($pfile, "<tr><td>posted by: ".$getї'name']." | ".$getї'date']."</td></tr></table>");
fclose($pfile);
}
}
echo("</table>\n\t\t\t<tr>\n\t\t\t\t<td> </td>\n\t\t\t\t</tr>\n\t\t\t\t</td>\n\t\t\t</tr></table>\n\t\t</td></tr>");
echo("\n<tr>\n\t<td align=center><a href=http://www.webiam.net target=_blank><font face=".variables2(font)." size=1>© 2002 web i am networks</a></td>\n\t</tr>\n </table>");
}
PaTTeR
Forum Commoner
Posts: 56 Joined: Wed Jul 10, 2002 7:39 am
Location: Bulgaria
Contact:
Post
by PaTTeR » Wed Aug 07, 2002 11:36 am
Are you shure that you have a dir 'newsdir' , and php user have permitions to write in 'newsdir'
learning_php_mysql
Forum Commoner
Posts: 27 Joined: Sun Aug 04, 2002 12:58 pm
Location: WA
Post
by learning_php_mysql » Wed Aug 07, 2002 12:25 pm
would it work if i chmod only the directory? or would i have to add a command in my loop to chmod the files individually?
learning_php_mysql
Forum Commoner
Posts: 27 Joined: Sun Aug 04, 2002 12:58 pm
Location: WA
Post
by learning_php_mysql » Wed Aug 07, 2002 6:24 pm
took me about 3 hours but i solved the problem
Code: Select all
function shout_box() {
echo("\t<td valign=top><table width=550 cellspacing=0 cellpadding=0 border=0 align=center>");
echo("\n\t\t<tr>\n\t\t\t<td align=right><table width=100% cellspacing=0 cellpadding=0 border=0 valign=top align=center>");
echo("\n\t\t<tr>\n\t\t\t<td height=15></td>\n\t\t\t</tr>");
echo("\n\t\t<tr>\n\t\t\t<td><table width=95% cellspacing=0 cellpadding=0 border=0 valign=top align=center>\n\t\t\t</tr>");
$result=mysql_query("SELECT * FROM shout_box");
$stop=(mysql_num_rows($result)-1);
if($stop > 10) {
$stop=10;
}
for($j=$stop; $j>=0; $j--) {
$get=mysql_fetch_array($result);
$open ="/users/coolfreepages.com/r85anderson/newsdir/news".$j.".php";
$pfile="/newsdir/news".$j.".php";
if(is_file($open)) {
fopen($open, "r");
echo("<tr><td><iframe src=".$pfile." frameborder=1 scrolling=yes height=80 width=550></iframe></td></tr>");
echo("<tr><td height=15></td></tr>");
//fclose($open);
}
else {
$file=fopen($open, "w+");
//fopen($open, "w+");
chmod($open, 0777);
fwrite($file, "<script language=javascript>function open() {return true;}open();</script><body bgcolor=".variables2(bgcolor)."><table width=100% bgcolor=".variables2(t_bgcolor)." cellspacing=0 cellpadding=0 border=0>\n\t<tr>\n\t\t<td><font face=".variables2(font)." color=".variables2(f_color1).">".$getї'headline']."</td></tr>");
fwrite($file, "<tr><td style="font-size: ".variables2(f_size2).""><font face=".variables2(font)." color=".variables2(f_color2).">".$getї'post']."</td></tr>");
fwrite($file, "<tr><td align=right style="font-size: ".variables2(f_size1).""><font face=".variables2(font)." color=".variables2(f_color2).">posted by: ".$getї'name']." | ".$getї'date']."</td></tr></table>");
fclose($file);
echo("<tr><td><iframe src=".$pfile." frameborder=1 scrolling=yes height=80 width=550></iframe></td></tr>");
echo("<tr><td height=15></td></tr>");
}
}
echo("</table>\n\t\t\t\t</td>\n\t\t\t</tr></table>\n\t\t</td></tr>");
echo("\n<tr>\n\t<td align=center><a href=http://www.webiam.net target=_blank><font face=".variables2(font)." size=1>© 2002 web i am networks</a></td>\n\t</tr>\n </table>");
}