mysql_error(): 提供的参数不是有效的 MySQL-Link 资源

mysql_error(): supplied argument is not a valid MySQL-Link resource

我正在使用此脚本将 csv 文件加载到 mysql:

$sql = mysql_query("LOAD DATA LOCAL INFILE '".$target_file."' 
                                INTO TABLE tbl_avaibility FIELDS TERMINATED BY ',' 
                                OPTIONALLY ENCLOSED BY '\"'
                                LINES TERMINATED BY '\n'
                                IGNORE 1 LINES
                                (name, total_downtime, mttr, mtbf, uptimepercentage, grup, periode, trim, cek, key1, grouptype, groupname, iphost, ha, tier, manage, sec, min, hour, downtime, cekpercentage, test, status, ipvm, namevm, statevm, hostvm, cluster, vcenter, cekcok) SET nik_user='$user_id'");

if(!$sql)
{
    mysql_error($sql);
}

在我最新的 mysql 中它正在工作。

我的服务器是 mysql 的旧版本,mysql 5.0 在我上传文件时出现错误。

mysql_error(): 提供的参数不是有效的 MySQL-Link 资源

谁能告诉我该怎么做。

不要向 mysql_error() 提供你的 mysql_query() 结果($sql),要么将其保留为空,要么向其提供来自 [=14= 的资源 link ].

http://php.net/manual/en/function.mysql-error.php

string mysql_error ([ resource $link_identifier = NULL ] )

在此示例中,$link_identifier 是可选的,将您的代码更改为...

if(!$sql)
{
    echo mysql_error();
}