if($filename != ‘.’ && $filename != ‘…’
First, do not use fancy quotes. Turn them off in your editor. Which editor are you using?
Next, check filename for one dot and two dots, not three.
Lastly, to use prepared statements, you set up, or, PREPARE, the insert operation. Then for each file, execute the insert. Something, loosely like this:
$stmt = $conn->prepare("INSERT INTO playlist (name, dir) VALUES ( ?, ? )");
$stmt->bind_param("s", $filename, $dbdir1);
// set parameters and execute
$dir1 = “C:\xampp\htdocs\php\playlist1”;
$files = scandir($dir1);
foreach($files as $filename) {
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if($filename != "." && $filename != ".." && $ext == "mp3" ){
$dbdir1 = $dir1 . "\" . $filename;
$name = $filename;
$stmt->execute();
}
Untested, just set up to loop thru the filenames without fancy-quotes and PREPARED-STATEMENTs.