我有一个PHP,我用它来创建使用PHP的文件夹和子文件夹。我想从我的中文数据库中获取数据并用中文创建文件夹。以下是我的代码:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "dtable";
//session_start();
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
mysqli_set_charset($conn,"utf8");
// Check connection
if (!$conn) {
die("Connection failed: " . mysql_connect_error());
}
$upload = 'E://demo';
$str = '';
$str1 = '';
if(isset($_POST['userid'],$_POST['pid']))
{
$userid = trim($_POST["userid"]);
$pid = trim($_POST["pid"]);
$sql = "SELECT * FROM demo WHERE username = '$userid' and password = '$pid'";
$result = mysqli_query($conn,$sql);
$row = mysqli_fetch_array($result);
$target = $upload.'/'.$row['week'].'/'.$row['day1'].'/'.$row['client'].'/'.$row['brand'].'/'.$row['sn'].'/';
if(!file_exists($target))
{
mkdir($target,0777,true);
}
?>
我的数据库中的数据是中文的。当数据是英文时,这完全正常,但一旦我将其更改为中文,它就开始给我错误。