|
|
|
ทำไงให้ php เพิ่มข้อมูลลง mysql เป็นภาษาญี่ปุ่นครับ ลองหลายวิธีแล้วยังไม่ได้ |
|
|
|
|
|
|
|
ลองเอา code นี้ไปดูครับ
Code (PHP)
$host = 'localhost';
$user = 'username';
$password = 'password';
$db = 'db';
$conetion=mysql_connect($host,$user,$password) or die("ไม่สามารถติดต่อฐ้านข้อมูลได้");
$db=mysql_select_db($db) or die("ไม่สามารถเลือกฐานข้อมูลได้");
mysql_db_query($db,"SET NAMES shift-jis");
mysql_query("SET character_set_database ='shift-jis'");
mysql_query("SET character_set_results ='shift-jis'");
mysql_query("SET character_set_client ='shift-jis'");
mysql_query("SET character_set_connection ='shift-jis'");
mysql_query("SET character_set_system ='shift-jis'");
mysql_query("collation_connection = shift-jis");
mysql_query("collation_database = shift-jis");
mysql_query("collation_server = shift-jis");
|
ประวัติการแก้ไข 2013-02-20 16:39:16
|
|
|
|
Date :
2013-02-20 16:38:40 |
By :
KenJeRoKung |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณครับ KenJeRoKung ลองดูแปบนึงครับ
|
|
|
|
|
Date :
2013-02-20 16:45:34 |
By :
antz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<meta http-equiv="Content-Type" charset="utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?
$host="localhost";
$username="root";
$password="";
$db="db";
$tb="user";
mysql_connect( $host,$username,$password) or die ("ติดต่อกับฐานข้อมูล Mysql ไม่ได้ ");
mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้"); /* ทำการเลือกฐานข้อมูลก่อน */
mysql_query("SET NAMES shift-jis");
mysql_query("SET character_set_database ='shift-jis'");
mysql_query("SET character_set_results ='shift-jis'");
mysql_query("SET character_set_client ='shift-jis'");
mysql_query("SET character_set_connection ='shift-jis'");
mysql_query("SET character_set_system ='shift-jis'");
mysql_query("collation_connection = shift-jis");
mysql_query("collation_database = shift-jis");
mysql_query("collation_server = shift-jis");
$sql="Select * From $tb where id='2'";
$db_query=mysql_query($sql);
$num_rows=mysql_num_rows($db_query); /* นับ Reccord ที่พบ */
?>
<table width="91%" border="1" align="center">
<tr>
<td width="8%">
<div align="center">no.</div>
</td>
<td width="8%">
<div align="center">kakakutai</div>
</td>
<td width="8%">
<div align="center">address</div>
</td>
<td width="8%">
<div align="center">table.</div>
</td>
<tr>
<?
$a=0;
while($a < $num_rows)
{
$result = mysql_fetch_array($db_query);
$id=$result[id];
$status=$result[status];$min_size=$result[min_size];
$htype=$result[htype];$max_size=$result[max_size];
$mapping=$result[mapping];$menseki=$result[menseki];
$boi=$result[boi];$madori=$result[madori];
$area=$result[area];$takasa=$result[takasa];
$name=$result[name];$takasa2=$result[takasa2];
$address=$result[address];$kansei=$result[kansei];
$builder=$result[builder];$message=$result[message];
$contact=$result[contact];$setsubi=$result[setsubi];
$kakakutai2=$result[kakakutai];$comment= $result[comment];
$price=$result[price];$memo=$result[memo];
$min_price=$result[min_price];$table=$result[table];
$max_price=$result[max_price];$i0=$result[i0];
$i1= $result[i1];$i6=$result[i6];
$i2=$result[i2];$i7=$result[i7];
$i3=$result[i3];$a0=$result[a0];
$i4=$result[i4];$additional=$result[additional];
$i5=$result[i5];$kigyou=$result[kigyou];
$kakakutai="$kakakutai2";
// $p = preg_replace('/[^a-z0-9\_\- ]/i', '', $str);
echo $sql2="update data_f3 set kakakutai='$result[kakakutai]' where id='759'";
mysql_query($sql2)or die(mysql_error()) ;
?>
<tr>
<td width="8%">
<div align="center"><?echo"$id";?></div>
</td>
<td width="8%">
<div align="center"><?echo"$kakakutai2";?></div>
</td>
<td width="8%">
<div align="center"><?echo"$address";?></div>
</td>
<td>
<div align="center"><?echo"$table";?></div>
</td>
</tr>
<?
$a++;
}
?> </table>
<?
echo"<center><br>จำนวน Reccord = $num_rows</center>";
mysql_close();
?>
</body>
</html>
ยัง ไม่ได้ครับ ลองรันแล้ว ไม่รุ้เป็นเพราะอะไร
|
|
|
|
|
Date :
2013-02-20 16:55:21 |
By :
antz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
นี่เป็นส่วนที่ผมไล่ ลองดูมาทั้งหมดครับ จากคำแนะนำต่างๆ
Code (PHP)
/*
mysql_query("USE $dbname;")or die(mysql_error());
mysql_query("SET charecter_set_results=utf8");
mysql_query("SET charecter_set_client=utf8");
mysql_query("SET_charecter_set_connection=utf8");
*/
/*
mysql_query("SET NAMES shift-jis");
mysql_query("SET character_set_database ='shift-jis'");
mysql_query("SET character_set_results ='shift-jis'");
mysql_query("SET character_set_client ='shift-jis'");
mysql_query("SET character_set_connection ='shift-jis'");
mysql_query("SET character_set_system ='shift-jis'");
mysql_query("collation_connection = shift-jis");
mysql_query("collation_database = shift-jis");
*/
mysql_query("collation_server = euc-jp");
mysql_query("SET NAMES euc-jp");
mysql_query("SET charecter_set_results=utf8");
mysql_query("SET charecter_set_client=utf8");
mysql_query("SET_charecter_set_connection=utf8");
/*
mysql_query("collation_server = shift-jis");
mysql_query("SET NAMES utf8");
mysql_query("SET charecter_set_results=utf8");
mysql_query("SET charecter_set_client=utf8");
mysql_query("SET_charecter_set_connection=utf8");
*/
/*
mysql_query("collation_server = utf-8");
mysql_query("SET NAMES utf-8");
mysql_query("SET charecter_set_results=utf-8");
mysql_query("SET charecter_set_client=utf-8");
mysql_query("SET_charecter_set_connection=utf-8");
*/
/*
mysql_query("SET NAMES utf-8");
mysql_query("SET character_set_database ='utf-8'");
mysql_query("SET character_set_results ='utf-8'");
mysql_query("SET character_set_client ='utf-8'");
mysql_query("SET character_set_connection ='utf-8'");
mysql_query("SET character_set_system ='utf-8'");
mysql_query("collation_connection = utf-8");
mysql_query("collation_database = utf-8");
*/
/*
mysql_query("SET NAMES euc-jp");
mysql_query("SET character_set_database ='euc-jp'");
mysql_query("SET character_set_results ='euc-jp'");
mysql_query("SET character_set_client ='euc-jp'");
mysql_query("SET character_set_connection ='euc-jp'");
mysql_query("SET character_set_system ='euc-jp'");
mysql_query("collation_connection = 'euc-jp'");
mysql_query("collation_database = 'euc-jp'");
*/
|
|
|
|
|
Date :
2013-02-21 09:21:44 |
By :
antz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
$dbname="tdcthai_test";
$link=mysql_connect("localhost","root","")or die(mysql_error());
mysql_query("SET charecter_set_results=euc-jp");
mysql_query("SET charecter_set_client=euc-jp");
mysql_query("SET_charecter_set_connection=euc-jp");
mysql_query("USE $dbname;")or die(mysql_error());
$i=0;
$result1=mysql_query("select * from data_f order by id asc limit 5");
while($dbarr=mysql_fetch_array($result1)){
$i=$i+1;
$id[$i]=$dbarr['id'];
echo $kakakutai1[$i]=$dbarr['kakakutai'];
}
mysql_close($link);
//------------------
$dbname2="tdcthai_test";
$link2=mysql_connect("localhost","root","")or die(mysql_error());
mysql_query("SET charecter_set_results=utf8");
mysql_query("SET charecter_set_client=utf8");
mysql_query("SET_charecter_set_connection=utf8");
mysql_query("USE $dbname2;")or die(mysql_error());
for($n=1;$n<=$i;$n++){
mysql_query("insert into data_f_new (id,kakakutai) valuse ('$id[$n]','$kakakutai1[$n]')");
}
mysql_close($link2);
echo "ok";
?>
อันนี้รันในเครื่องไม่ได้แต่รันที่โฮส ได้ อ่ะครับ
|
|
|
|
|
Date :
2013-02-21 14:32:18 |
By :
antz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<?php
$dbname="tdcthai_test";
$link=mysql_connect("localhost","root","")or die(mysql_error());
mysql_query("SET charecter_set_results=euc-jp");
mysql_query("SET charecter_set_client=euc-jp");
mysql_query("SET_charecter_set_connection=euc-jp");
mysql_query("USE $dbname;")or die(mysql_error());
$i=0;
$result1=mysql_query("select * from data_f order by id asc limit 5");
while($dbarr=mysql_fetch_array($result1)){
$i=$i+1;
$id[$i]=$dbarr['id'];
echo $kakakutai1[$i]=$dbarr['kakakutai'];
}
mysql_close($link);
//------------------
$dbname2="tdcthai_test";
$link2=mysql_connect("localhost","root","")or die(mysql_error());
mysql_query("SET charecter_set_results=utf8");
mysql_query("SET charecter_set_client=utf8");
mysql_query("SET_charecter_set_connection=utf8");
mysql_query("USE $dbname2;")or die(mysql_error());
for($n=1;$n<=$i;$n++){
mysql_query("insert into data_f_new (id,kakakutai) valuse ('$id[$n]','$kakakutai1[$n]')");
}
mysql_close($link2);
echo "ok";
?>
ได้แระ อยู่ที่ การกดเซฟไฟล์อ่ะ เซงเลย
|
|
|
|
|
Date :
2013-02-22 10:40:48 |
By :
arsachi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จะต้อง Save เป็นอะไรครับ
|
|
|
|
|
Date :
2013-02-22 10:42:58 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|