I have an array of file names
$files = array();
$dirName = getcwd()."/../";
$dir = opendir('../'); // open the cwd..also do an err check.
while(false != ($file = readdir($dir))) {
if(($file != ".") and ($file != "..") and ($file != "index.php")and ($file != "img") and ($file != "__MACOSX")) {
$files[] = $file; // put in array.
}
}
I want to insert a new record into projects table for each filename e.g.
foreach($files as $file) {
$filename = mysql_real_escape_string($file);
$query = "INSERT INTO `projects` (`id`, `name`) VALUES (NULL,$filename)";
$result = mysql_query($query, $connection);
echo $result;
}
However has now effect on the database.