Hi there. I wrote a sript in PHP to create files. Just for simplicity sake I just named them all numbers (by the total number of files - 1). However, as I built up the script, I decided to name them all by the title of the content that I was putting within each file. There are thousands of files to delete that were named by number, so I just left them all in the directory. When I run the script now, it creates a few files with the title as the name, and leaves the rest of them alone. Can you look at the script and see if you can figure out why all the files aren't being created? Thank you.
<?php
include "includes/config.php";
echo "<table>";
$result2 = @("Select * from tutorials order by id desc");
$total = mysql_affected_rows();
while($total > 1)
{
$total = ($total - 1);
?>
<table width=100%>
<tbody>
<?php
$result = mysql_query("Select * from tutorials where id =\"$total\"");
$myrow = mysql_fetch_array($result);
//if (!$id == '')
//{
if (!$myrow[title] == '')
{
$comments = $myrow['comments'];
$url2 = $SERVER["REQUEST_URI"];
$urlsplits = split("",$url2);
$urlcut = $urlsplits[1];
$urlsplits = str_replace("tutorial$urlcut","",$url2);
$urlsplits = str_replace(""," ",$urlsplits);
$urlsplits = str_replace(".html","",$urlsplits);
$urlsplits = str_replace("/","",$urlsplits);
echo trim(ucwords($urlsplits));
//open file for appending, create if does not exist
//If you use write mode, everything in the file is overwritten
$id = $myrow[id];
$title = $myrow['title'];
$datemade = $myrow['datemade'];
$views = $myrow['views'];
$author = $myrow['homepage'];
$tutorial = $myrow['tutorial'];
$icon = $myrow['icon'];
$comments = $myrow['comments'];
$url = $title;
$url = str_replace(" ","",$url);
$url = str_replace("-","_",$url);
$url = str_replace("©","",$url);
$url = str_replace("£","",$url);
$url = str_replace("&","",$url);
$url = str_replace("<","",$url);
$url = str_replace(">","",$url);
$url = str_replace("#","",$url);
$url = str_replace("!","",$url);
$url = str_replace("$","",$url);
$url = str_replace("%","",$url);
$url = str_replace("","",$url);
$url = str_replace("*","",$url);
$url = str_replace("(","",$url);
$url = str_replace(")","",$url);
$url = str_replace("=","",$url);
$url = str_replace("+","",$url);
$url = str_replace("?","",$url);
$url = str_replace("/","",$url);
$url = str_replace(",","",$url);
$url = str_replace(".","",$url);
$url = strtolower($url);
$url = "$url"."tutorials.html";
$b = $author;
$b = str_replace("http://","",$b);
$b = str_replace("www.","",$b);
$b = str_replace("/","",$b);
$myFile = fopen("/home/misc/public_html/distancelearning/$url", "w");
print $url;
// Lock file
flock($myFile, 1);
$jobtext =<<< END
<HTML><HEAD><title> $title</title>
<META NAME="keywords" CONTENT="articles, tutorials, fonts"></head><body>
<table width="550" bgcolor="#FFFFFF" border="0" cellspacing="0" cellpadding="5"><tr><td colspan="3">
<FONT face="arial,sans-serif" color="#336699"><a href="http://www.mysitesname.com/distancelearning/$url" target="_blank"><font face="arial,sans-serif" size="-1" color="#336699"><strong>$title</strong></font></FONT></SPAN></A></FONT>
<FONT style="FONT-SIZE: 8pt" face="arial,sans-serif" size="-1"><B> - </B><FONT color="#d29117"><font face="arial,sans-serif" size="-1" color="#d29117"> </font> </FONT><B> - </B></FONT>
<A onclick="http://www.mysitesname.com/return blnk('$id')" href="#"><FONT face="arial,sans-serif" size="-2"><SPAN class"broken">Report Broken Link</SPAN></FONT></A>
</tr></td><tr>
<td width="13%" rowspan="5" valign="top">
<font face="arial,sans-serif" size="-1"> </SPAN>
<a href="http://www.mysitesname.com/distancelearning/$url" target="_blank">
<IMG height="40" src="http://www.mysitesname.com/tuticons/$icon" width="40" border="0"></A></td>
<td width="87%"><font face="arial,sans-serif" size="-1">$comments</font></td>
</tr><tr>
<td align="left"><font face="arial,sans-serif" size="-2" color="#1b2834"><A href="http://www.mysitesname.com/author/$author.html"><font color="#1b2834">Author: $author</font></A></FONT>
<FONT color="#045300"></FONT></FONT>
<font face="arial,sans-serif" size="-2" color="#1b2834">| $datemade | </FONT><FONT color="#1b2834">
<font face="arial,sans-serif" size="-2">Views: $views </FONT><SPAN style="FONT-SIZE: 8pt"></span><tr><td align="left" colspan="5"><hr color="#dbdbdb" size="1"></td></tr>
</tr></table></body></html>
END;
//Write line to bottom of file
rewind($myFile);
fputs($myFile, $jobtext);
//release lock
flock($myFile, 3);
//close file
fclose($myFile);
?>
</tbody>
</table>
<?
}
}
?>