当前位置: 动力学知识库 > 问答 > 编程问答 >

php - mysql_connect() [function.mysql-connect] Error

问题描述:

mysql_connect is throwing an error on my clients page 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.

I need to know what exactly went wrong and how to rectify it. . .please help me out guys

<?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>';

}

}

?>

my config.php File below:

<?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));?>

网友答案:

You have a typo in this line, there's an extra apostrophe in the username.

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

You should use the constants that you defined earlier:

$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");
分享给朋友:
您可能感兴趣的文章:
随机阅读: