|
Hi,
When inserting my array into my database, I look up the values in the table and it just appears as; NULL, NULL, NULL. is there anything i can do to my code to stop this. I hear i need to use serialize, but im not quite sure how to use this function. this is my code;
function opening($file)
{
$pattern = "(\.txt$)| (\.php$)";
if(eregi($pattern, $file)){
$file_handle = fopen($file, "r");
$contents = file($file);
while (!feof($file_handle)){
$data = fgets($file_handle);
$words = explode(' ' , $data);
foreach($words as $word)
{
$sql = "INSERT INTO webdata VALUES($word);";
if (mysql_query($sql)){
print "successful <p>";
}
}
}
}
else {
echo "Cant open that file type <p>"; }
}
function getfiles($dirname=".") {
$pattern = "(\.txt$)| (\.php$)";
$files = array();
if($handle = opendir($dirname)) {
while(false !== ($file = readdir($handle))){
if(eregi($pattern, $file) || is_dir($file))
echo "$file <br />";
opening($file);
}
closedir($handle);
}
return($files);
}
|