php การแสดงผล ตัวอักษรผิดไป

ผมนำโค้ดของ php มารวมกันเพื่อทำโปรแกรมเกียรติบัตร  เมื่อนำมาแสดงผล ภาษาจะเพี้ยนไปเพราะอะไรครับ  
<?php
//กำหนดตัวแปรเพื่อนำไปใช้งาน
include ("connectb.php");
// เริ่มติดต่อฐานข้อมูล
$connect = mysql_connect($hostname, $user, $password) or die("ติดต่อฐานข้อมูลไม่ได้");
mysql_query( "SET NAMES TIS620" );
// เลือกฐานข้อมูล
$db = mysql_select_db($dbname) or die("เลือกฐานข้อมูลไม่ได้");
//mysql_query("SET NAMES  tis620_thai_ci"); // เพิ่มบรรทัดนี้เขามา ตามที่คุณแนะ
//mysql_query("SET NAMES UTF8"); // เพิ่มบรรทัดนี้เขามา ตามที่คุณแนะนำมา

// คำสั่ง SQL และสั่งให้ทำงาน
$sql = "select * from $tblname where barcode ='$barcode'";
$dbquery = mysql_query($sql, $connect) or die ("ส่งคิวรีไม่ได้");
$result = mysql_fetch_array($dbquery);
        $barcode = $result[barcode];
        $title = $result[title];
        $author = $result[author];
        $price = $result[price];
        $type = $result[type];
        $year = $result[year];
echo "<Center>";
echo "<B><Font size=4 color=blue>เรกคอร์ดของหนังสือที่มีหมายเลข Barcode </Font><Font size=4 color=red> ".$barcode."</Font></B>";
echo "<Font size=4>";
echo "<Form action=\"test.php\" method=\"post\">";     // ส่งค่าไปอัปเดท
echo "<Input type=\"hidden\" name=\"barcode\" Size=\"60\" value=\"$barcode\">";
echo "<Table bgcolor=yellow>";
echo "<Tr><Td>Title</Td> <Td><Input type=\"text\" name=\"title\" Size=\"60\" value=\"$title\"></Td></Tr>";
echo "<Tr><Td>Author</Td> <Td><Input type=\"text\" name=\"author\" Size=\"30\" value=\"$author\"></Td></Tr>";
echo "<Tr><Td>Price</Td> <Td><Input type=\"text\" name=\"price\" Size=\"4\" value=\"$price\"> </Td></Tr>";
echo "<Tr><Td>Type</Td> <Td><Input type=\"text\" name=\"type\" Size=\"20\" value=\"$type\"></Td></Tr>";
echo "<Tr><Td>Year</Td> <Td><Input type=\"text\" name=\"year\" Size=\"4\" value=\"$year\"></Td></Tr>";
echo "</Table>";
echo "<Br><Input type=\"Submit\" value=\"print เกียรติบัตร\">";

echo "</Form>";
echo "</Font>";
echo "</Center>";
echo "<Input type=\"hidden\" name=\"barcode\" Size=\"60\" value=\"$title\">";


    $font = 'THSarabun Bold_2.ttf'; //font
    $font_size = 20; //font size

    $string = $title; // String
    
    $im = imagecreatefromjpeg("bg_code.jpg"); // Create TempImage from Path image
    $color = imagecolorallocate($im, 0, 0, 0); // font color
    $pxX = ((imagesx($im))/2)-50; //position X
    $pxY = 25; //Position Y

    imagettftext($im, $font_size, 0, $pxX, $pxY, $color, $font, $string); //Execute Text
    $file_path = "test.jpg"; //New Path Image
    imagejpeg($im,$file_path); // New Image
    imagedestroy($im); //Destroy Temp Image
?>

<img src="test.jpg?<?php print date("ms");?>" alt="test" width="500" height="500" />
แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่