我有这段代码将目录中的文件名插入数据库
<?php
include("db.php");
$path = 'C:\Users\Firdavs\Desktop\Ypp';
$directories = new RecursiveIteratorIterator(
new ParentIterator(new RecursiveDirectoryIterator($path)),
RecursiveIteratorIterator::SELF_FIRST);
foreach ($directories as $directory) {
if($directory->isDir())
{
foreach (new DirectoryIterator($directory) as $file)
{
if($file->isDot()) continue;
if($file->isFile())
{
$filename=$file->getFilename();
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if($ext=='docx')
{
mysqli_query($con,"INSERT INTO Organ (Name) VALUES ('$filename')");
$filename=mysql_real_escape_string($filename);
}
}
}
}
}
?>
它显示如下警告
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user ''@'localhost' (using password: NO) in Y:\home\localhost\www\jurist\import.php on line 22
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in Y:\home\localhost\www\jurist\import.php on line 22
但代码仍在工作,将文件名插入数据库;
我的 db.php 正在关注
$con= mysqli_connect("localhost","root","mypassword","jurist") or die("Error " . mysqli_error($con));
可能是什么问题?