set Database ตามด้านแต่ สงสัยว่า ทำมีผลออกมาเป็น "no" ทั้งๆ ที่ set ขนาดใหญ่ ไว้แล้ว
แต่หากตัดข้อความให้สั้นลง ผลออกมาเป็น yes
ดังนั้น ข้อมูลใหญ่่ขนาดนี้ ควรทำอย่างไรดีคะ
Code (SQL)
CREATE TABLE IF NOT EXISTS `page` (
`id_page` int(5) NOT NULL,
detail1` mediumtext COLLATE utf8_unicode_ci NOT NULL
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Code (PHP)
<?php
$detail1="Super Tuesday saw 11 states voting, from Massachusetts in the east to Alaska in the north-west. A 12th state, Colorado, held a caucus - won by Mr Sanders - but does not actually select its delegates until April.
Tuesday allocates nearly a quarter of Republican delegates, and about a fifth of Democratic delegates, who will elect their respective presidential candidates at party conventions in July. No candidate has yet won enough delegates to secure their party's nomination.
Favourites
Mrs Clinton, a former secretary of state, and Mr Trump, a property tycoon, entered Super Tuesday as favourites to win the vast majority of states for their respective parties.
The Democratic frontrunner delivered her victory speech from Miami, having moved her campaign to Florida for the primary there on 15 March, in common with other candidates.";
include("storeScripts/dbConnect.php");
$conn = mysqli_connect($serverName,$userName,$userPassword,$dbName);
$conn->set_charset('utf8');
$sql="update page set detail1='".$detail1."' where id_page=1";
$query = mysqli_query($conn,$sql);
if($query)
{
echo "ok";
exit;
}else
{
echo "No";
}
mysqli_close($conn);
?>
ลองตัดข้อความ
"Super Tuesday saw 11 states voting,
from Massachusetts in the east to Alaska in the north-west.
A 12th state, Colorado, held a caucus - won by Mr Sanders - but does not actually select its delegates until April.
Tuesday allocates nearly a quarter of Republican delegates, and about a fifth of Democratic delegates, who will elect their respective presidential candidates at party conventions in July. ";
ขนาดนี้ จะบันทึกใน Mysql แต่พอ
ลองเพิ่มเป็น บันทัดด้านล่างต่อท้าย ข้อความนี้ไม่แสดงผลใน Mysql
" No candidate has yet won enough delegates to secure their party's nomination.";
$sql="update page set detail1='".mysqli_real_escape_string($detail1)."' where id_page=1";
แนะนำเขียนเป็น oop จะง่ายกว่าครับ Code (PHP)
<?php
$detail1="Super Tuesday saw 11 states voting, from Massachusetts in the east to Alaska in the north-west. A 12th state, Colorado, held a caucus - won by Mr Sanders - but does not actually select its delegates until April.
Tuesday allocates nearly a quarter of Republican delegates, and about a fifth of Democratic delegates, who will elect their respective presidential candidates at party conventions in July. No candidate has yet won enough delegates to secure their party's nomination.
Favourites
Mrs Clinton, a former secretary of state, and Mr Trump, a property tycoon, entered Super Tuesday as favourites to win the vast majority of states for their respective parties.
The Democratic frontrunner delivered her victory speech from Miami, having moved her campaign to Florida for the primary there on 15 March, in common with other candidates.";
include("storeScripts/dbConnect.php");
$conn = new mysqli($serverName,$userName,$userPassword,$dbName);
$conn->set_charset('utf8');
$sql="update page set detail1='".$conn->real_escape_string($detail1)."' where id_page=1";
$query = $conn->query($sql) or die( $conn->error."<br>$sql");
echo "ok";