简体   繁体   English

我在php中遇到错误

[英]I am getting errors in php

I am getting this error and I have done everything I can think about. 我收到了这个错误,我做了我能想到的一切。 Can someone help me out I have been working on this all day. 有人可以帮助我,我一整天都在努力。 I am still a little newbie at it. 我还是一个新手。 Thanks. 谢谢。

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'username'@'localhost' (using password: YES) in C:\\wamp\\www\\member-form.php on line 81 error on connect 警告:mysql_connect()[function.mysql-connect]:在第81行的C:\\ wamp \\ www \\ member-form.php中,用户'用户名'@'localhost'(使用密码:YES)拒绝访问连接错误

else{
$hostname="localhost";
$database="contact";
$mysql_login="username";
$mysql_password="password";

81.if (!($db = mysql_connect($hostname, $mysql_login , $mysql_password))){
    echo "error on connect";
}
else{
if (!(mysql_select_db($databse, $db))){
    echo mysql_error();
    echo "<br>error on table connection";
}
else{
    $SQL="Insert into tblUsers(username,password,firstname,lastname,email,address,city,state,zip, phone,signupDate)values)'".$_POST['username']."',PASSWORD('".$_POSR['password1']."'),'".$_POST['firstname']."','".$_POST['lastname']."','".$_POST['address']."','".$_POST['city']."','".$_POST['state']."','".$_POST['zip']."','".$_POST['phone']."',NOW())";
    mysql_query($SQL);
    if (is_numeric(mysql_insert_id())){
        header("Location:member-content.php?name=".$_POST['username']);
    }
    else{
        echo "Sorry, there was an errot.Please try again ot contact the administrator";
    }
    mysql_close($db);//closeing out connection,done for now
  }
   }
 }

?>

The mysql username or password in your some of your configuration file is incorrect. 您的某些配置文件中的mysql用户名或密码不正确。 You should see what kind of code is on member-form.php line 81 as mentioned in the error. 您应该看到错误中提到的member-form.php第81行上的代码类型。

Edit: Create a new file test.php and put following code in it, and see in your browser what you get: 编辑:创建一个新文件test.php并将以下代码放入其中,并在浏览器中看到您得到的内容:

<?php
mysql_connect("localhost", "Web_User", "my1230") or die(mysql_error());
echo "Connected to MySQL<br />";
?>

Please don't use mysql it isn't save and it is deprecated use mysqli or pdo. 请不要使用mysql它不保存并且不推荐使用mysqli或pdo。 here below is an example for mysqli 下面是mysqli的一个例子

$servername = "localhost";
$username = "root";
$password = "thisisthepassword";
$dbname = "exampledatabase";
$conn = mysqli_connect($servername, $username, $password, $dbname);

This means you have set the wrong password. 这意味着您设置了错误的密码。 Check wherever you set your config that your password has the right case, and no typos. 检查您的配置设置,密码具有正确的大小写,并且没有拼写错误。

Your password is wrong for the user you are trying to login as. 您尝试登录的用户的密码错误。

The default WAMP username is "root" and password is blank. 默认WAMP用户名为“root”,密码为空。

mysql_connect("localhost","root");

If you go into your mySQL control panel, you can add users with passwords, and then add them to databases. 如果进入mySQL控制面板,可以为用户添加密码,然后将其添加到数据库中。 You need to create a user, and then add that user to the database with ALL privileges. 您需要创建一个用户,然后使用所有权限将该用户添加到数据库。 If you are using OS XI strongly suggest Sequel Pro to help simplify. 如果您正在使用OS XI强烈建议Sequel Pro帮助简化。

http://www.sequelpro.com/ http://www.sequelpro.com/

If you don't have OS X there are plenty of other tools such as: 如果您没有OS X,还有很多其他工具,例如:

http://www.phpmyadmin.net/home_page/index.php http://www.phpmyadmin.net/home_page/index.php

Now, once you do that (created a user), take the username and password and plug them into your script. 现在,一旦你这样做(创建了一个用户),拿出用户名和密码并将它们插入到你的脚本中。 The username is the username you just created and the password is the password associated with that user. 用户名是您刚刚创建的用户名,密码是与该用户关联的密码。

The error message tells you that you couldn't connect. 错误消息告诉您无法连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM