Page 1 of 1

file handling problem

Posted: Wed Aug 07, 2002 11:26 am
by learning_php_mysql
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() &#123;
	   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++) &#123;
			$get=mysql_fetch_array($result);
			$pfile="http://".variables2(subdomain).variables2(domain)."/newsdir/".$i.".php";
			if(is_file($pfile)) &#123;
				fopen($pfile, "r");
				    echo("<iframe src="".$pfile." frameborder=0 scrolling=auto height=80 width=500></iframe>");
				fclose($pfile);
				&#125;
			else &#123;
				fopen($pfile, "w+");
				    fwrite($pfile, "<table width=100% bgcolor=003333 cellspacing=0 cellpadding=0 border=0>\n\t<tr>\n\t\t<td>".$get&#1111;'headline']."</td></tr>");
				    fwrite($pfile, "<tr><td align=right>".$get&#1111;'post']."</td></tr>");
				    fwrite($pfile, "<tr><td>posted by: ".$get&#1111;'name']." | ".$get&#1111;'date']."</td></tr></table>"); 
				fclose($pfile);
				&#125;
			&#125;
			    echo("</table>\n\t\t\t<tr>\n\t\t\t\t<td>&nbsp;</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>&copy; 2002 web i am networks</a></td>\n\t</tr>\n    </table>");
		&#125;

Posted: Wed Aug 07, 2002 11:36 am
by PaTTeR
Are you shure that you have a dir 'newsdir' , and php user have permitions to write in 'newsdir'

Posted: Wed Aug 07, 2002 11:56 am
by learning_php_mysql
yeah i used the chmod command to 777 on the newdir through ftp

Posted: Wed Aug 07, 2002 12:25 pm
by learning_php_mysql
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?

Posted: Wed Aug 07, 2002 6:24 pm
by learning_php_mysql
took me about 3 hours but i solved the problem :D

Code: Select all

function shout_box() &#123;
    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) &#123;
		$stop=10;
		&#125;
		for($j=$stop; $j>=0; $j--) &#123;
			$get=mysql_fetch_array($result);
			$open ="/users/coolfreepages.com/r85anderson/newsdir/news".$j.".php";
			$pfile="/newsdir/news".$j.".php";
			if(is_file($open)) &#123;
				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);
				&#125;
			else &#123;
				$file=fopen($open, "w+");
				//fopen($open, "w+");
				chmod($open, 0777);
				    fwrite($file, "<script language=javascript>function open() &#123;return true;&#125;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&#1111;'headline']."</td></tr>");
				    fwrite($file, "<tr><td style="font-size: ".variables2(f_size2).""><font face=".variables2(font)." color=".variables2(f_color2).">".$get&#1111;'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&#1111;'name']." | ".$get&#1111;'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>");
				&#125;
			&#125;
		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>&copy; 2002 web i am networks</a></td>\n\t</tr>\n    </table>");
		&#125;