2014-09-25 77 views
-4

的mysql_connect是我的客户页Heremysql_connect()函数[function.mysql-CONNECT]错误

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 = '[email protected]'; 
     $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: <[email protected]>' . "\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: [email protected]: 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 <[email protected]>!", $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","[email protected]#"); // 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

认为信息是明确的。您的用户没有权限访问数据库。 – Jens 2014-09-25 06:06:24

+1

只需在提示中更改您的用户名/密码,然后再发布。 – tom 2014-09-25 09:13:11

回答

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"); 
+0

我改变了,但同样的错误Barmar – Zain 2014-09-25 07:00:55

+0

然后你的用户名或密码一定是错的。 – Barmar 2014-09-25 07:01:22

+0

哦其他编码是好的吗? – Zain 2014-09-25 07:01:51

相关问题