QR Code ไม่สามารถอ่านเครื่องหมาย & ได้

ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา QR Code ไม่สามารถอ่านเครื่องหมาย & ได้

QR Code ไม่สามารถอ่านเครื่องหมาย & ได้



ขอรบกวนหน่อยครับ อันนี้งมอยู่นาน แต่ก็ทำไม่ได้
เกรงว่าจะสื่อสารไม่เข้าใจจึงเอาโค้ดมาทั้งหมดเลย

คือต้องการ  เก็บค่า url ไว้ในตัวแปร $qrreport[]  และ จากนั้นเก็บค่าตัวแปรไว้ใน QR CODE อีกทีนึง  เพื่อให้ลิงค์ไปตามที่อยู่ที่ต้องการ
แต่ผลก็คือ  QR CODE ไม่สามารถประมวลผลกับตัวเครื่องหมาย & ได้
ดังนั้นจึงลอง echo ตัวแปร$qrreport[] ผลปรากฏว่าเครื่องหมาย & ทำงานได้เป็นปกติ

พยายามลองแล้วแต่ไม่ได้  จึงได้สอบถามมา ณ ที่นี้ครับ.


ขอบคุณครับ.


// ฐานข้อมูล

 
CREATE TABLE `startcode` (
  `no` int(7) NOT NULL auto_increment,
  `student_code` varchar(100) NOT NULL,
  `identification_card` varchar(100) NOT NULL,
  PRIMARY KEY  (`no`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
 
-- 
-- dump ตาราง `startcode`
-- 
 
INSERT INTO `startcode` VALUES (1, '2521478', '2211300081053');
INSERT INTO `startcode` VALUES (2, '3907814', '2211300081061');
INSERT INTO `startcode` VALUES (3, '4749452', '2261200071234');
INSERT INTO `startcode` VALUES (4, '5163872', '2261200071255');



 

// code

<html>
<body bgcolor="#FFFFFF">
<? include ("qrlib.php"); 
 
$host="localhost";
$username="root";
$pass_word="";
$db="test";
$tb="startcode";
mysql_connect( $host,$username,$pass_word) or die ("ติดต่อกับฐานข้อมูล Mysql ไม่ได้ ");
mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้");
mysql_query("set NAMES tis620 ");
echo "<table><tr>";
$sql = "select * From $tb";
$Per_Page =8; /* ตั้งค่าแสดงผลต่อหน้า $Per_Page */
if(!$Page)
$Page=1;
 
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
 
$result = mysql_query($sql);
$Page_start = ($Per_Page*$Page)-$Per_Page;
$Num_Rows = mysql_num_rows($result);
 
if($Num_Rows<=$Per_Page)
$Num_Pages =1;
else if(($Num_Rows % $Per_Page)==0)
$Num_Pages =($Num_Rows/$Per_Page) ;
else 
$Num_Pages =($Num_Rows/$Per_Page) +1;
 
$Num_Pages = (int)$Num_Pages;
 
if(($Page>$Num_Pages) || ($Page<0))
print "<center><b>จำนวน $Page มากกว่า $Num_Pages เกิดข้อผิดพลาด<b></center>";
 
$sql = "select * From $tb order by no asc LIMIT $Page_start , $Per_Page";
 
//ส่วนแสดงผล
$result = mysql_query($sql);
 
While($row= mysql_fetch_array($result))
{
 
 
$no[] = $row["no"];
$student_code[] = $row["student_code"];
$identification_card[]= $row["identification_card"];
$student_code2 = $row["student_code"];
$identification_card2= $row["identification_card"];
 
// ทดสอบเครื่องหมาย  &    เพื่อเชื่อม url
//$qrreport[] = "http://www.myweb.com/studentshow.php?student_code=$student_code2"."&amp;"."identification_card=$identification_card2 "; 
//$qrreport[] = "http://www.myweb.com/studentshow.php?student_code=$student_code2&identification_card=$identification_card2 "; 
 
$qrreport[] = "http://www.myweb.com/studentshow.php?student_code=$student_code2&amp;identification_card=$identification_card2 "; 
 
 
 
 
QRcode::png("$qrreport", "studentqrcode/$student_code.png", 'L', 4, 2);
}
echo"<table><tr>";
for($i=0;$i<count($no);$i++) {
if($i%2==1)
{
// กรณีมีตัวเดียว
echo "<td>";
 
?>
<table width="496" height="140" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC" class="TabBrd">
  <tbody>
    <tr> 
      <td height="18" align="right" colspan="2" bgcolor=" <?echo "527fd2";?>"><div align="left"><b style="color:#FFFFFF; font-size:13px;"> 
          <font size="4.5"><strong> </strong></font><font  color="#ffffff" size="4.5"><strong>student_code 
          :&nbsp;</strong></font><font size="4.5"><strong> </strong> <?echo $student_code[$i];?></font><br />
          </b></div></td>
    </tr>
    <tr> 
      <td width="143" rowspan="2" align="center"><img src="gen_qrcode.php?w=<?=$qrreport[$i]?>" alt=""><b style="color:#FFFFFF; font-size:13px;"><font  color="#000000" size="4.5"><strong><br>
        </strong></font></b></td>
      <td width="351" height="9" >&nbsp;</tr>
    <tr> 
      <td height="9" >&nbsp;</tr>
    <tr> 
      <td height="18" colspan="2" align="center"> <div align="left"><b style="color:#FFFFFF; font-size:13px;"><font  color="#0000FF" size="4.5"><strong>link 
          :&nbsp;</strong></font><font  color="#000000" size="4.5"><strong><?echo "$qrreport[$i]"?></strong></font></b></div></td>
    </tr>
</table>
<?
echo"</td></tr>";
}
else
{
//กรณีมีสองตัว
echo "<td>";
?>
<table width="496" height="140" align="center" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC" class="TabBrd">
  <tbody>
    <tr> 
      <td height="18" align="right" colspan="2" bgcolor=" <?echo "527fd2";?>"><div align="left"><b style="color:#FFFFFF; font-size:13px;"> 
          <font size="4.5"><strong> </strong></font><font  color="#ffffff" size="4.5"><strong>student_code 
          :&nbsp;</strong></font><font size="4.5"><strong> </strong> <?echo $student_code[$i];?></font><br />
          </b></div></td>
    </tr>
    <tr> 
      <td width="143" rowspan="2" align="center"><img src="gen_qrcode.php?w=<?=$qrreport[$i]?>" alt=""><b style="color:#FFFFFF; font-size:13px;"><font  color="#000000" size="4.5"><strong><br>
        </strong></font></b></td>
      <td width="351" height="9" >&nbsp;</tr>
    <tr> 
      <td height="9" >&nbsp;</tr>
    <tr> 
      <td height="18" colspan="2" align="center"><div align="left"><b style="color:#FFFFFF; font-size:13px;"><font  color="#ffffff" size="4.5"><strong><font color="#0000FF">link 
          :</font>&nbsp;</strong></font><font  color="#000000" size="4.5"><strong><?echo "$qrreport[$i]"?></strong></font></b></div></td>
    </tr>
</table>
<? echo"</td>";
}
}
 
echo"</tr></table>";
mysql_close();
?>
<br>
พบทั้งหมด<b> 
<?= $Num_Rows;?>
</b> รายการ รวมทั้งหมด: <b> 
<?=$Num_Pages;?>
</b> หน้า : 
<?/* ????????????????? */
if($Prev_Page) 
echo " <a href='$PHP_SELF?Page=$Prev_Page'><< ย้อนกลับ </a>";
for($i=1; $i<$Num_Pages; $i++){
if($i != $Page)
echo "[<a href='$PHP_SELF?Page=$i'>$i</a>]";
else 
echo "<b> $i </b>";
}
/*สร้างปุ่มเดินหน้า */
if($Page!=$Num_Pages)
echo "<a href ='$PHP_SELF?Page=$Next_Page'> หน้าถัดไป>> </a>"; 
?> 
</body>
</html>
 
 


Giggstar 1.46.204.xxx 26-12-2018 09:27:21

คำแนะนำ และการใช้งาน

สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก


  • ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
  • เปลี่ยน


    ( หรือ เข้าใช้งานผ่าน Social Login )

 ความคิดเห็นที่ 1
ตรวจสอบไฟล์
 
gen_qrcode.php?w=<?=$qrreport[$i]?>
 
โดยลองเรียกผ่าน url โดยตรง แล้วดูค่าตัวแปร $_GET['w'] ว่าค่าถูกส่งมาถูกต้องหรือไม่
ซึ่งค่า $_GET['w'] ในไฟล์ gen_qrcode.php จะต้องอยู่ในรูปแบบ 
 
https://www.myweb.com/student.php?a=1&b=2
 
แนวทางลองใช้ url urlencode() แปลงค่าก่อนส่ง แล้วใช้ urldecode() แปลงค่ากลับในหน้ารับค่า
 
เช่น ไฟล์ a.php
 
$qrreport[] = urlencode("http://www.myweb.com/studentshow.php?student_code=$student_code2&identification_card=$identification_card2"); 
 
 
ไฟล์ gen_qrcode.php รับค่าตัวแปร $_GET['w'] โดยแปลงค่ากลับก่อนนำไปใช้งาน
 
$_GET['w'] = urldecode(trim($_GET['w']));


ninenik 180.183.103.xxx 26-12-2018
 ความคิดเห็นที่ 2
ขอบคุณครับ.


giggstar 1.47.143.xxx 27-12-2018 01:08
 ความคิดเห็นที่ 3
ได้แล้วครับ ขอบคุณมากเลยครับ..


giggstar 1.47.143.xxx 27-12-2018 01:13
1






เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ