Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in C:\AppServ\www\training\condb.php on line 2
äÁèÊÒÁÒöµÔ´µèÍ MySql ä´é
แต่เมือผมเช็คจาก condb.php ถูกต้องน่ะครับ
Code (PHP)
<?
$conn = mysql_connect('localhost','root',' 9899')
or die("ไม่สามารถติดต่อ MySql ได้");
mysql_select_db("db_eng")
or die ("ไม่สามารถเลือกใช้งานฐานข้อมูลได้");
mysql_query("SET NAMES tis620");
?>
Access denied for user 'root'@'localhost' (using password: YES)
User หรือ Pass ผิดครับ เวลาเข้า phpMyAdmin คุณใช้ user, pass อะไรครับ ก็ใส่ตัวนั้นแหละ
Date :
2014-05-29 09:09:02
By :
arm8957
No. 2
Guest
Code (PHP)
<?
$conn = mysql_connect('localhost','root',' 9899')
or die("ไม่สามารถติดต่อ MySql ได้");
mysql_select_db("db_eng")
or die ("ไม่สามารถเลือกใช้งานฐานข้อมูลได้");
mysql_query("SET NAMES tis620");
?>
จากบรรทัดที่ 2 ผมเช็คแล้วครับตรงครับ แต่ผมสงสัยว่า
มีอีกตัวหนึ่งครับ คือ อยู่ใน foder include
class_main.inc
Code (PHP)
<?
error_reporting(1);
class admin_control {
// ======= Start variable of class ===========
/*var $host = "localhost";
var $database = "thawangpha_1";
var $user = "thawangpha_1";
var $password = "9899";*/
var $database = "db_eng";
var $user = "root";
var $password = "9899";
var $link_con = 0;
var $sqlquery;
var $result;
var $count;
var $ERRNO;
var $ERROR;
var $totalpage;
var $startx;
// ======= Stop variable of class ===========
// ======= Start method of class ===========
function admin_control () {
global $HTTP_HOST;
$this->link_con = mysql_connect($this->host,$this->user,$this->password);
mysql_select_db($this->database,$this->link_con);
mysql_db_query($this->database,"SET NAMES tis620");
}
function send_cmd($query){
$this->sqlquery = $query;
$this->result = mysql_query($query,$this->link_con);
$this->ERRNO = mysql_errno();
$this->ERROR = mysql_error();
$this->count = mysql_num_rows($this->result);
return $this->count;
}
function get_id () {
return mysql_insert_id($this->link_con);
}
function get_data(){
return mysql_fetch_row($this->result);
}
function fetch_data(){
return mysql_fetch_array($this->result);
}
function data_seek($torow){
return mysql_data_seek($this->result,$torow);
}
function num_rows(){
return $this->count;
}
function page_count($data_record,$pagesize,$pageid){
$this->totalpage = (int)($data_record / $pagesize);
if(($data_record % $pagesize) != 0){
$this->totalpage += 1;
}
if(isset($pageid)){
$this->startx = $pagesize * ($pageid -1);
}else{
$pageid = 1;
$this->startx = 0;
}
return $this->startx;
}
function show_error() {
echo $this->sqlquery."<br>".mysql_errno().":".mysql_error();
}
function free_result(){
mysql_free_result($this->result);
}
function close() {
mysql_close($this->link_con);
}
function convert_date($date)
{
list ($YYYY, $MM, $DD) = split ('[/.-]', $date);
$date_out="$DD/$MM/$YYYY";
return $date_out;
}
function convert_date_to_db($date)
{
list ($YYYY, $MM, $DD) = split ('[/.-]', $date);
$date_out="$YYYY-$MM-$DD";
return $date_out;
}
// ======= Stop method of class ===========
}
// end of class
$db = new admin_control();
//---------------- Setup Enviralment --------
/*function textreplace($text){
$searchtext ="\"";
$replacetext=""";
return str_replace ($searchtext, $replacetext, $text);
}
function inservalue($text){
$searchtext ="\'";
$replacetext="''";
return str_replace ($searchtext, $replacetext, $text);
}*/
function textreplace($text){
$searchtext ="\"";
$replacetext=""";
return str_replace ($searchtext, $replacetext, $text);
}
function inservalue($text){
$searchtext ="\'";
$replacetext="''";
return str_replace ($searchtext, $replacetext, renHTML($text));
}
function querysql($text){
$searchtext ="\'";
$replacetext="''";
return str_replace ($searchtext, $replacetext, $text);
}
//????????? renHTML() ???????????????????????????????? HTML ???????????????????????????????????
function renHTML($strTemp){
$strTemp = nl2br(htmlspecialchars($strTemp));
return $strTemp;
}
?>