gpt4 book ai didi

php - 使用密码 NO 的用户拒绝 MySQL 错误访问

转载 作者:行者123 更新时间:2023-11-29 01:10:16 25 4
gpt4 key购买 nike

我一直收到这个错误:

Warning: mysql_query() [function.mysql-query]: Access denied for user 'mcabinet'@'localhost' (using password: NO) in /home/mcabinet/public_html/games/db_edit/airportmadness4.php on line 3

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/mcabinet/public_html/games/db_edit/airportmadness4.php on line 3
No Database found.

这是我的整个 .php 页面:

<?php
include("../templates/base/template2/mysql_connect.php");




$gametitle = "Airport Madness TEST";
$gamedescription = "DESCRIPtion testing a description. LOL !";
$image1url = "http://website-gamesite.com/games/images/lhfdsjk.jpg";
$categorycode = "adv";
$gametitle2 = "airportmadnesstest";


mysql_query("INSERT INTO Games VALUES (null,'$gametitle','$gamedescription','$image1url','$categorycode','0','$gametitle2'") or die ("Error Inserting Values into the Games Table");

?>

谢谢!我刚开始使用 PHP 和 MySQL。

编辑:这是包含文件的内容:

<?php

$db_host = "localhost";
$db_username = "mcabinet_admin";
$db_password = "4jf8ido9A";
$db_name = "mcabinet_games";

@mysql_connect($db_host,$db_username,$db_password) or die ('MySQL Not found // Could Not Connect.');
@mysql_select_db("$db_name") or die ("No Database found.");


?>

根据您的提示进行编辑后,我仍然收到错误。

编辑:我做了更多更改。这很奇怪,因为当我从数据库中获取内容时,内容显示正常,但仍然显示错误。当我运行单独的脚本,尝试添加行时,它甚至无法连接。

最佳答案

尝试将 include 移动到第一个查询行上方!像这样

<?php
include("../templates/base/template2/mysql_connect.php");
$query = mysql_query("SELECT * FROM Games WHERE id = '1' ");

要发出 MySQL 请求,您需要先连接。

关于php - 使用密码 NO 的用户拒绝 MySQL 错误访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10873803/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com