 |
ช่วยผมทีครับ แก้ปัญหาภาษาไทยไม่ได้เลย ทั้งใน data base และตัว browser |
|
 |
|
|
 |
 |
|
เอา Code หน้าค้นหามาครัส
|
 |
 |
 |
 |
Date :
2013-11-30 13:00:49 |
By :
itpcc |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ก่อนหน้านี้พอเป็นภาษาไทยได้ พอผมเพิ่ม code ในส่วนของลบไปแล้วเกิดปัญหาครับ ผมเคยถามเรือง code การลบมาแล้วครับ
Code (PHP)
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#0000FF">
<div align="center">
<br>
<?
require('common.inc.php');
mysql_connect($server, $user, $password) or die("ติดต่อระบบฐานข้อมูลไม่ได้");
mysql_select_db($dbname) or die("เลือกฐานข้อมูลไม่ได้");
#------------ลบข้อมูล------------#
$ptn_id = $_GET['del_ptn']; #รับค่าเพื่อเป็นเงื่อนไขในการลบ
if(!empty($ptn_id)){
$del = mysql_query("DELETE FROM patient WHERE ptn = '$ptn_id' LIMIT 1");
if($del){
echo 'ลบข้อมูลแล้ว';
} else {
echo 'ไม่สามารถลบข้อมูลได้';
}
}
#--------จบคำสั่งลบข้อมูล-----#
//ตรวจสอบฟิลด์ที่ใช้: เริ่ม
$search=(integer)$search;
$query="SELECT * FROM patient ORDER BY ptn";
//ตรวจสอบฟิลด์ที่ใช้: จบ
$dbquery=mysql_db_query($dbname, $query);
$num_rows=mysql_num_rows($dbquery);
if ($num_rows>0){
echo "<table border=0><tr><td><b><font face='MS Sans Serif, Microsoft Sans Serif'>แสดงผรายชื่อผู้สมัครงาน </font><font face='MS Sans Serif, Microsoft Sans Serif' color='red'>\"$search\"</font></b></td></tr></table>";
echo "<br><table border=0><tr bgcolor='#FFCC99'><td><font face='MS Sans Serif, Microsoft Sans Serif' color='black'><b>รหัสผู้สมัคร</b></font></td><td><font face='MS Sans Serif, Microsoft Sans Serif' color='black'><b>ชื่อ-สกุล</b></font></td><td><font face='MS Sans Serif, Microsoft Sans Serif' color='black'><b>อายุ</b></font></td><td><font face='MS Sans Serif, Microsoft Sans Serif' color='black'><b>ที่อยู่</b></font></td><td><font face='MS Sans Serif, Microsoft Sans Serif' color='green'><b>คลิกเพื่อดูข้อมูล</b></font></td><td><font face='MS Sans Serif, Microsoft Sans Serif' color='red'><b>คลิกเพื่อแก้ไขข้อมูล</b></font></td></tr>";
$bg='#FFCCFF';
$i=0;
while ($i<$num_rows){
$result=mysql_fetch_array($dbquery);
$ptn=$result['ptn'];
$ptprefix=$result['ptprefix'];
$ptname=$result['ptname'];
$ptsurname=$result['ptsurname'];
$birthday=$result['birthday'];
$address=$result['address'];
$age=date('Y-m-d')-$birthday;
if ($bg=='#FFCCFF'){
$bg='#FFFFCC';
}else{
$bg='#FFCCFF';
}
echo "<tr bgcolor=$bg><td><font face='MS Sans Serif, Microsoft Sans Serif'>$ptn</font></td><td><font face='MS Sans Serif, Microsoft Sans Serif'>$ptprefix $ptname $ptsurname</font></td><td><font face='MS Sans Serif, Microsoft Sans Serif'>$age</font></td><td><font face='MS Sans Serif, Microsoft Sans Serif'>$address</font></td><td><font face='MS Sans Serif, Microsoft Sans Serif'><a href='displaypatient.php?ptn=$ptn&fieldsearch=$fieldsearch&search=$search' target='mainFrame'>[ดูข้อมูล]</a></font></td><td><font face='MS Sans Serif, Microsoft Sans Serif'><a href='editpatient_form.php?ptn=$ptn&fieldsearch=$fieldsearch&search=$search' target='mainFrame'>[แก้ไขข้อมูล]</a></font> <a href='$_SERVER[PHP_SELF]?del_ptn=$ptn&fieldsearch=$fieldsearch&search=$search' target='mainFrame'>[ลบข้อมูล]</a></td></tr>";
$i++;
}
echo "</table>";
echo "<br><table border=0><tr><td><b><font face='MS Sans Serif, Microsoft Sans Serif' color='green'>แสดงผรายชื่อผู้สมัครงาน</font></b></td></tr></table>";
mysql_close();
echo "<br><font face='MS Sans Serif, Microsoft Sans Serif'><a href='index.html'>[กลับหน้าแสดง/แก้ไข]</a></font>";
}
?>
</div>
</body>
</html>
บรรทัดนี้น่ะครับที่พอผมเพิ่มเข้าไปแล้วมีปัญหาเรืองภาษาไทยครับ
Code (PHP)
#------------ลบข้อมูล------------#
$ptn_id = $_GET['del_ptn']; #รับค่าเพื่อเป็นเงื่อนไขในการลบ
if(!empty($ptn_id)){
$del = mysql_query("DELETE FROM patient WHERE ptn = '$ptn_id' LIMIT 1");
if($del){
echo 'ลบข้อมูลแล้ว';
} else {
echo 'ไม่สามารถลบข้อมูลได้';
}
}
#--------จบคำสั่งลบข้อมูล-----#
|
 |
 |
 |
 |
Date :
2013-11-30 13:02:36 |
By :
newpro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อีกอันแสดงภาษาไทยได้ ก็ลองไปดูโค้ดหน้า "แสดงข้อมูลผู้สมัครงาน"ว่าต่างกับหน้าค้นหาอย่างไร.....ก็น่าจะเห็นความแตกต่างว่า "ภาษาไทย" มันอยู่ตรงไหนนะ
|
 |
 |
 |
 |
Date :
2013-11-30 13:44:21 |
By :
telesyn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หน้าค้นหาครับ แก้ยังไม่ได้เลยครับ รบกวนช่วยดูทีครับว่าเกิดปัญหาอะไรครับ
อันนี้หน้า ค้นหาครับ
Code (PHP)
<?
require('common.inc.php');
mysql_connect($server, $user, $password) or die("ติดต่อระบบฐานข้อมูลไม่ได้");
mysql_select_db($dbname) or die("เลือกฐานข้อมูลไม่ได้");
#------------ลบข้อมูล------------#
$ptn_id = $_GET['del_ptn']; #รับค่าเพื่อเป็นเงื่อนไขในการลบ
if(!empty($ptn_id)){
$del = mysql_query("DELETE FROM patient WHERE ptn = '$ptn_id' LIMIT 1");
if($del){
echo 'ลบข้อมูลแล้ว';
} else {
echo 'ไม่สามารถลบข้อมูลได้';
}
}
#--------จบคำสั่งลบข้อมูล-----#
//ตรวจสอบฟิลด์ที่ใช้: เริ่ม
$search=(integer)$search;
$query="SELECT * FROM patient ORDER BY ptn";
//ตรวจสอบฟิลด์ที่ใช้: จบ
$dbquery=mysql_db_query($dbname, $query);
$num_rows=mysql_num_rows($dbquery);
if ($num_rows>0){
echo "<table border=0><tr><td><b><font face='MS Sans Serif, Microsoft Sans Serif'>แสดงผรายชื่อผู้สมัครงาน </font><font face='MS Sans Serif, Microsoft Sans Serif' color='red'>\"$search\"</font></b></td></tr></table>";
echo "<br><table border=0><tr bgcolor='#FFCC99'><td><font face='MS Sans Serif, Microsoft Sans Serif' color='black'><b>รหัสผู้สมัคร</b></font></td><td><font face='MS Sans Serif, Microsoft Sans Serif' color='black'><b>ชื่อ-สกุล</b></font></td><td><font face='MS Sans Serif, Microsoft Sans Serif' color='black'><b>อายุ</b></font></td><td><font face='MS Sans Serif, Microsoft Sans Serif' color='black'><b>ที่อยู่</b></font></td><td><font face='MS Sans Serif, Microsoft Sans Serif' color='green'><b>คลิกเพื่อดูข้อมูล</b></font></td><td><font face='MS Sans Serif, Microsoft Sans Serif' color='red'><b>คลิกเพื่อแก้ไขข้อมูล</b></font></td></tr>";
$bg='#FFCCFF';
$i=0;
while ($i<$num_rows){
$result=mysql_fetch_array($dbquery);
$ptn=$result['ptn'];
$ptprefix=$result['ptprefix'];
$ptname=$result['ptname'];
$ptsurname=$result['ptsurname'];
$birthday=$result['birthday'];
$address=$result['address'];
$age=date('Y-m-d')-$birthday;
if ($bg=='#FFCCFF'){
$bg='#FFFFCC';
}else{
$bg='#FFCCFF';
}
echo "<tr bgcolor=$bg><td><font face='MS Sans Serif, Microsoft Sans Serif'>$ptn</font></td><td><font face='MS Sans Serif, Microsoft Sans Serif'>$ptprefix $ptname $ptsurname</font></td><td><font face='MS Sans Serif, Microsoft Sans Serif'>$age</font></td><td><font face='MS Sans Serif, Microsoft Sans Serif'>$address</font></td><td><font face='MS Sans Serif, Microsoft Sans Serif'><a href='displaypatient.php?ptn=$ptn&fieldsearch=$fieldsearch&search=$search' target='mainFrame'>[ดูข้อมูล]</a></font></td><td><font face='MS Sans Serif, Microsoft Sans Serif'><a href='editpatient_form.php?ptn=$ptn&fieldsearch=$fieldsearch&search=$search' target='mainFrame'>[แก้ไขข้อมูล]</a></font> <a href='$_SERVER[PHP_SELF]?del_ptn=$ptn&fieldsearch=$fieldsearch&search=$search' target='mainFrame'>[ลบข้อมูล]</a></td></tr>";
$i++;
}
echo "</table>";
echo "<br><table border=0><tr><td><b><font face='MS Sans Serif, Microsoft Sans Serif' color='green'>แสดงผรายชื่อผู้สมัครงาน</font></b></td></tr></table>";
mysql_close();
echo "<br><font face='MS Sans Serif, Microsoft Sans Serif'><a href='index.html'>[กลับหน้าแสดง/แก้ไข]</a></font>";
}
?>
|
 |
 |
 |
 |
Date :
2013-11-30 14:16:04 |
By :
newpro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อันนี้หน้าที่แสดงข้อมูลภาษาไทยได้ครับ

Code (PHP)
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
</head>
<body bgcolor="#FFFFFF" text="#0000FF">
<div align="center">
<br>
<?
include('thai.inc.php');
require('common.inc.php');
mysql_connect($server, $user, $password) or die("ติดต่อระบบฐานข้อมูลไม่ได้");
mysql_select_db($dbname) or die("เลือกฐานข้อมูลไม่ได้");
$query="SELECT * FROM patient WHERE ptn='$ptn'";
$dbquery=mysql_db_query($dbname, $query);
$result=mysql_fetch_array($dbquery);
$ptn=$result['ptn'];
$ptprefix=$result['ptprefix'];
$ptname=$result['ptname'];
$ptsurname=$result['ptsurname'];
$sex=$result['sex'];
$birthday=$result['birthday'];
$address=$result['address'];
$district=$result['district'];
$province=$result['province'];
$zipcode=$result['zipcode'];
$telephone=$result['telephone'];
$disease=$result['disease'];
$allergy=$result['allergy'];
$remark=$result['remark'];
$date=$result['date'];
$age=date('Y-m-d')-$birthday;
$y1=substr($birthday,0,4)+543;
$m1=(integer)substr($birthday,5,2)-1;
$d1=(integer)substr($birthday,8,2);
$birthday=$d1.' '.$ThaiFullMonth[$m1].' '.$y1;
$y2=substr($date,0,4)+543;
$m2=(integer)substr($date,5,2)-1;
$d2=(integer)substr($date,8,2);
$date=$d2.' '.$ThaiFullMonth[$m2].' '.$y2;
?>
<table width="641" border="1">
<tr>
<td bgcolor="#FFCC99" bordercolor="#0000FF"><b><font face="MS Sans Serif, Microsoft Sans Serif" color="#000000">แสดงข้อผู้สมัครงาน</font></b></td>
</tr>
<tr>
<td bordercolor="#0000FF">
<table width="100%" border="0" cellpadding="5">
<tr>
<td width="29%" bgcolor="#FFFFCC"><strong>รหัสใบสมัครงาน</strong></td>
<td width="71%"><font face="MS Sans Serif, Microsoft Sans Serif"><? echo $ptn ?></font></td>
</tr>
<tr>
<td width="29%" bgcolor="#FFFFCC"><strong>คำนำหน้าชื่อ</strong></td>
<td width="71%"><font face="MS Sans Serif, Microsoft Sans Serif"><? echo $ptprefix ?></font></td>
</tr>
<tr>
<td bgcolor="#FFFFCC"><strong>ชื่อ-นามสกลุล</strong></td>
<td><font face="MS Sans Serif, Microsoft Sans Serif"><? echo $ptname ?></font></td>
</tr>
<tr>
<td width="29%" bgcolor="#FFFFCC"><strong>เบอร์โทรศัพท์</strong></td>
<td width="71%"><font face="MS Sans Serif, Microsoft Sans Serif"><? echo $ptsurname ?></font></td>
</tr>
<tr>
<td width="29%" bgcolor="#FFFFCC"><b><font face="MS Sans Serif, Microsoft Sans Serif">ที่อยู่</font></b></td>
<td width="71%"><font face="MS Sans Serif, Microsoft Sans Serif"><? echo $address ?></font></td>
</tr>
<tr>
<td width="29%" bgcolor="#FFFFCC"><b><font face="MS Sans Serif, Microsoft Sans Serif">อำเภอ</font></b></td>
<td width="71%"><font face="MS Sans Serif, Microsoft Sans Serif"><? echo $district ?></font></td>
</tr>
<tr>
<td width="29%" bgcolor="#FFFFCC"><b><font face="MS Sans Serif, Microsoft Sans Serif">จังหวัด</font></b></td>
<td width="71%"><font face="MS Sans Serif, Microsoft Sans Serif"><? echo $province ?></font></td>
</tr>
<tr>
<td width="29%" bgcolor="#FFFFCC"><b><font face="MS Sans Serif, Microsoft Sans Serif">รหัสไปรษณีย์</font></b></td>
<td width="71%"><font face="MS Sans Serif, Microsoft Sans Serif"><? echo $zipcode ?></font></td>
</tr>
<tr>
<td width="29%" bgcolor="#FFFFCC"><b><font face="MS Sans Serif, Microsoft Sans Serif">อีเมล์ (e-mail) </font></b></td>
<td width="71%"><font face="MS Sans Serif, Microsoft Sans Serif"><? echo $disease ?></font></td>
</tr>
<tr>
<td width="29%" bgcolor="#FFFFCC"><b><font face="MS Sans Serif, Microsoft Sans Serif">ตำแหน่งที่สมัคร</font></b></td>
<td width="71%"><font face="MS Sans Serif, Microsoft Sans Serif"><? echo $remark ?></font></td>
</tr>
</table>
</td>
</tr>
</table>
<?
echo "<br><a href='searchpatient.php?fieldsearch=$fieldsearch&search=$search'>[กลับหน้าแรก]</a></font><br>";
?>
<br>
</div>
</body>
</html>
งงมากเลยครับ
|
 |
 |
 |
 |
Date :
2013-11-30 14:19:04 |
By :
newpro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
|
 |
 |
 |
 |
Date :
2013-11-30 14:33:18 |
By :
telesyn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อันนี้คือก่อนหน้าที่ใช้ code การลบข้อมูลยังเป็นภาษาไทยอยู่ครับ

แต่พอผมใช้ code ที่ใช้ลบ ก็ไม่อ่านภาษาไทยเลยครับ ผมใช้ code ตัวนี้ที่ขอคำแนะนำมาครับ
Code (PHP)
#------------ลบข้อมูล------------#
$ptn_id = $_GET['del_ptn']; #รับค่าเพื่อเป็นเงื่อนไขในการลบ
if(!empty($ptn_id)){
$del = mysql_query("DELETE FROM patient WHERE ptn = '$ptn_id' LIMIT 1");
if($del){
echo 'ลบข้อมูลแล้ว';
} else {
echo 'ไม่สามารถลบข้อมูลได้';
}
}
#--------จบคำสั่งลบข้อมูล-----#
เกิดจากสาเหตุอะไรเหรอครับผมงงมากเลยครับ
|
 |
 |
 |
 |
Date :
2013-11-30 15:10:29 |
By :
newpro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยทีครับ ผมลอง set ตัว connect data base เป็น UTF8 แล้วครับ
<?
$server="localhost";
$user="xxxxxxx";
$password="xxxxxx";
$dbname="xxxxx";
mysql_query("Set Name UTF8");
?>
ผลการรันที่ได้ครับ

ช่วยผมทำครับทำไหงดี
|
 |
 |
 |
 |
Date :
2013-12-02 09:32:54 |
By :
newpro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใครพอจะแนะนำได้บ้างไหมครับ
|
 |
 |
 |
 |
Date :
2013-12-02 10:02:55 |
By :
newpro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลืมเติม s ครับ แล้วก็ใส่รหัสผ่านให้ถูกต้องครับ
Code (PHP)
mysql_query("SET NAMES UTF8"); #คำสั่งนี้ใส่ก่อนการ insert ครับ
แล้วก็อย่าลืม
Code (PHP)
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
 |
 |
 |
 |
Date :
2013-12-02 10:13:42 |
By :
arm8957 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมใส่ตามที่บอกแล้วครับ ยังไม่หายเลยครับ
<?
$server="localhost";
$user="xxxx";
$password="xxxxx";
$dbname="xxx";
mysql_query("SET NAMES UTF8");
?>
ในหน้าที่ไม่เป็นภาษาไทยส่วนบนผมใส่แบบนี้ครับ
html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body bgcolor="#FFFFFF" text="#0000FF">
<div align="center">
<br>
ก็ยังคงฟ้องแบบนี้ครับ
Warning: mysql_query() [function.mysql-query]: Access denied for user 'apache'@'localhost' (using password: NO) in /home/varatchanu/domains/accesslink.co.th/public_html/dcis/common.inc.php on line 6
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/varatchanu/domains/accesslink.co.th/public_html/dcis/common.inc.php on line 6
จะแก้ปัญหาอย่างไหรดีครับ
|
 |
 |
 |
 |
Date :
2013-12-02 10:30:28 |
By :
newpro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผู้ใช้ดังกล่าวไม่มีสิทธ์ใช้งาน หรือใส่ user และ pass เพื่อเชื่อมต่อกับฐานข้อมูลผิดครับ ในหน้า common.inc.php on line 6 อ่ะ (น่าจะอ่าน error สักนิดนะ)
<?
$server="localhost";
$user="xxxx";
$password="xxxxx";
$dbname="xxx";
mysql_query("SET NAMES UTF8");
?>
|
ประวัติการแก้ไข 2013-12-02 11:19:22 2013-12-02 11:23:07
 |
 |
 |
 |
Date :
2013-12-02 11:18:36 |
By :
arm8957 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แต่พอผมเอา
mysql_query("SET NAMES UTF8") ออก กลับมาเหมือนเดิมน่ะครับ
<?
$server="localhost";
$user="varatchanu_dci";
$password="tK54R8gg";
$dbname="varatchanu_dci";
?>

ทำอย่างไรดีครับผม
|
 |
 |
 |
 |
Date :
2013-12-02 15:21:38 |
By :
newpro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
<?
//Connect database
$host = ".........";
$user = ".........";
$passwd = ".........";
$dbname = "sil";
mysql_connect($host,$user,$passwd) or die("Database Error");
mysql_select_db($dbname) or die("ฐานข้อมูลมีปัญหา");
mysql_query("SET NAMES UTF8");
mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_client=utf8");
mysql_query("SET character_set_connection=utf8");
?>
ปล. ใน database ใช้เป็น utf8_unicode_ci นะ
ส่วนใน head
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
|
 |
 |
 |
 |
Date :
2013-12-02 15:32:04 |
By :
jin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอาไว้ต่อจาก Connect
Code (PHP)
mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_client=utf8");
mysql_query("SET character_set_connection=utf8");
|
 |
 |
 |
 |
Date :
2013-12-02 15:59:46 |
By :
Krungsri |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|