mysql_connect()[function.mysql-connect]错误

时间:2014-09-25 06:02:39

标签: php mysql

mysql_connect在我的客户页面Here

上抛出错误
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'virkoh_com_user'@'localhost' (using password: YES) in C:\Inetpub\vhosts\virkoh.com\httpdocs\config.php on line 16
Couldn't make connection.

我需要知道到底出了什么问题,以及如何纠正它。 。 。请帮助我的人

<?php
include "config.php";
session_set_cookie_params(0);
$_SESSION['user']=1;
if(isset($_POST['submit'])){
    if($_POST['company_name'] == "" && $_POST['name'] == "" && $_POST['phone'] == "" && $_POST['email'] == "" && $_POST['message'] ==""){
        $error = "Please enter your companyname, name, phone number, email address and your enquiry message";
    }else{
        $company_name = $_POST['company_name'];
        $name =$_POST['name'];
        $phone = $_POST['phone'];
        $email = $_POST['email'];
        $message = $_POST['message'];
        $to = 'info@virkoh.com';
        $detail='Company Name:'.$_POST['company_name'].'<br>Name:'.$_POST['name'].'<br> Phone Number:'.$_POST['phone'].'<br> Email Address:'.$_POST['email'];
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-Type: text/html;
 charset=ISO-8859-1\r\n";
        $headers .= 'From: <info@virkoh.com>' . "\r\n";
        $message = '<br> Enquiry:'. $_POST['message'];
        $str_mail = "Dear Sir / Madam, <br> Thanks for contacting Virkoh Facility Management Services. We will revert back to you regarding your requirement at the earliest.We look forward to meet you soon.'<br><br>' With Best Regards, .<br> Admin<br>Email Address: info@virkoh.comWebsite: www.virkoh.com";
        //$mailsend=mail($to,$detail,$str_comments);
        //var_dump($mailsend);
        // to check whether the mail is sent or not mail($email, "Acknowledgement from Virkoh Facility Management Services",'<br>'.$str_mail, $headers);
        mail($to, "Shankar <info@virkoh.com>!", $detail.'<br>'.$message, $headers);
        $result = mysql_query("insert into feedbackvirkoh(company_name,name,phone,email,message) values ('$company_name','$name','$phone','$email','$message')") or die("SQL execution erroryyy : ".mysql_error());
        //header("Location:welcome.php");
        //echo '<script>alert("Thanks for contacting Virkoh Facility Management Services."); </script>';
    }
}
?>

我的config.php文件如下:

<?php
ob_start();
session_start();


//demo hosting username and password.....

    define ("DB_HOST", "localhost"); // set database host
define ("DB_USER", "virkoh_com_userr"); // set database user
define ("DB_PASS","virkoh123@#"); // set database password
define ("DB_NAME","virkoh_com_virkoh_3"); // set database name

define ("COOKIE_TIME_OUT", 10); //specify cookie timeout in days (default is 10 days)
define ('SALT_LENGTH', 9);

$link = mysql_connect("localhost","'virkoh_com_user","***") or die("Couldn't make connection.");
$db = mysql_select_db("virkoh_com_virkoh_3", $link) or die("Couldn't select database");

error_reporting(E_ALL & ~(E_STRICT|E_NOTICE));?>    

1 个答案:

答案 0 :(得分:1)

此行中有拼写错误,用户名中有一个额外的撇号。

$link = mysql_connect("localhost","'virkoh_com_user","***") or die("Couldn't make connection.");
                                   ^

您应该使用之前定义的常量:

$line = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die("Couldn't make connection.");
$db = mysql_select_db(DB_NAME, $link) or die("Couldn't select database");