0
I am working on a php on localhost where from the root folder will be to read all files and folders and insert into a MYSQL database but I’m having a hard time Can someone help us? obrgd ;)
/*CONNECT DB */
$link = mysqli_connect("localhost", "root", "usbw", "beifaserver") or die("Error " . mysqli_error($link));
mysqli_query($link,"delete from search");
/*CLEAN DB TABLE*/
function listFolderFiles($dir){ /*READ DIR/ File*/
$ffs = scandir($dir);
echo '';
foreach($ffs as $ff){
if($ff != '.' && $ff != '..'){
echo '';
if(is_dir($dir.'/'.$ff)){
echo $ff;
listFolderFiles($dir.'/'.$ff);
}
else{
echo ''.$ff.'';
$try = mysqli_query($link,"INSERT INTO search (title,url, dategrab)VALUES ('".$ff."', '".$dir."/".$ff."', '".date('2004-m-d H:i:s')."')");
if($try === false){
echo 'error - ';
echo mysqli_error($link);
}
}
echo '';
}
}
echo '
';
}
listFolderFiles('../');
?>
for the time being from the following error: SQLSTATE[HY000] [2002] No connection could be made because the target computer actively refused them.
– Cjjesus
I have one that gave but does not have path url so shows file:
– Cjjesus
This error (SQLSTATE[HY000] [2002]) occurs because Mysql is not enabled. If you use Xampp just go to Control Panel and activate it.
– Júnior