我一直在试图将一个目录路径插入到一个mySQL表(reportPath列)中。插入工作正常,但插入时忽略目录分隔符。例如,将D:\ public_html \ Testman \ config的路径插入为D:public_htmlTestmanconfig。我错过了什么?目录分隔符在插入mySQL时被忽略
下面是我的代码
<?php
include "config.php" ;
$dir = "csvreports";
$files = scandir($dir);
$fLocation=dirname(__FILE__).DIRECTORY_SEPARATOR;
foreach ($files as $key => $value)
{
if (substr($value, -4) == ".CSV")
{
mysql_query("INSERT INTO tableReports (reportPath, reportName) VALUES('$fLocation.$value','$value')");
}
}
?>
感谢Karolis/Halfdan,它工作。 –