我看到有很多这些类似的问题,但我找不到任何有类似代码的人.
脚本将文件上载到服务器,但我还想插入有关已上载文件的数据.文件上传应该没有错误,但phpmyadmin中的表保持为空.
error_log出错:
PHP Warning: mysql_query(): Access denied for user ''@'localhost' (using password: NO) in *path*/upload.php on line 65 PHP Warning: mysql_query(): A link to the server could not be established in *path*/upload.php on line 65
连接似乎正在工作,因为我通过TCP/IP获得输出"通过UNIX套接字127.0.0.1的Localhost"而不是网站上的mysql警告/错误.
连接脚本(uploadconnect.php):
connect_errno) { echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; } echo $mysqli->host_info . "\n"; $mysqli = new mysqli("127.0.0.1", "*username*", "*password*", "*database*", 3306); if ($mysqli->connect_errno) { echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; } echo $mysqli->host_info . "\n"; ?>
上传PHP脚本:
错误似乎发生在"mysql_query($ sql);" 在上传文件的第65行.
您已使用创建数据库连接mysqli
.这对过时的 mysql
库来说是不可用的.mysqli
一贯使用.