Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > ช่วยด้วยคับ พยายามหลายวันแล้ว You have an error in your SQL syntax; check the manual that corresponds to your



 

ช่วยด้วยคับ พยายามหลายวันแล้ว You have an error in your SQL syntax; check the manual that corresponds to your

 



Topic : 101177



โพสกระทู้ ( 7 )
บทความ ( 0 )



สถานะออฟไลน์




Code
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-10 , 10' at line 1:
SELECT * FROM student ORDER BY student ASC LIMIT -10 , 10




Code (PHP)
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

        <?
        $objConnect = mysql_connect("localhost", "root", "root") or die("Error");
        
        $objDB = mysql_select_db('skw');
        mysql_query("set names UTF8");
        ?>


    </head>
    <body>

        <form name="frmSearch" method="get" action="<?= $_SERVER['SCRIPT_NAME']; ?>">
            <table width="100%" border="1">
                <tr>
                    <th>ค้นหา
                        <input name="txtKeyword" type="text" id="txtKeyword" value="<?= $_GET["txtKeyword"]; ?>">
                        <input type="submit" value="Search"></th>
                    </th>

                    <?
                    $strSQL = "SELECT * FROM student WHERE (name LIKE '%".$_GET["txtKeyword"]."%' or email LIKE '%".$_GET["txtKeyword"]."%')";
                    $objQuery = mysql_query($strSQL) or die(mysql_error() . ":<br />" . $strSQL);
                    $Num_Rows = mysql_num_rows($objQuery) or die(mysql_error() . ":<br />" . $strSQL);


                    $Per_Page = 10;

                    $Page = $_GET["Page"];
                    if ($_GET["Page"]) {
                        $Page = 1;
                    }

                    $Prev_Page = $Page - 1;
                    $Next_Page = $Page + 1;

                    $Page_Start = (($Per_Page * $Page) - $Per_Page);

                    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;
                    }

                    $strSQL .=" ORDER BY id ASC LIMIT $Page_Start , $Per_Page";
                    $objQuery = mysql_query($strSQL) or die(mysql_error() . ":<br />" . $strSQL);
                    ?>

                <center><table border="1" width="100%">
                        <tr>
                            <th><div align="center">ลำดับ</div></th>
                        <th><div align="center">ชื่อ</div></th>
                        <th><div align="center">ปี</div></th>
                        <th><div align="center">สาขา</div></th>
                        <th><div align="center">คณะ</div></th>
                        <th><div align="center">เบอร์โทร</div></th>
                        <th><div align="center">Email</div></th>
                        <th><div align="center">เข้าร่วม</div></th>
                        </tr>

                        <?
                        while ($objResult = mysql_fetch_array($objQuery)) {
                            ?>

                            <tr>
                                <td><div align="center"><?= $objResult ["id"]; ?></div></td>
                                <td><div><?= $objResult["name"]; ?></div></td>
                                <td><div align="center"><?= $objResult ["year"]; ?></div></td>
                                <td><div align="center"><?= $objResult ["branch"]; ?></div></td>
                                <td><div align="center"><?= $objResult ["faculty"]; ?></div></td>
                                <td><div align="center"><?= $objResult ["tel"]; ?></div></td>
                                <td><div align="center"><?= $objResult ["email"]; ?></div></td>
                                <td><div align="center"><?= $objResult ["launch"]; ?></div></td>
                            </tr>
                        <? } ?>

                    </table>
                    <br>

                    Total <?= $Num_Rows; ?> Record : <?= $Num_Pages; ?> Page :

                    <?
                    if ($Prev_Page) {
                        echo "<a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtKeyword=&$_GET[txtKeyword]'><<Back<a/>";
                    }
                    for ($i = 1; $i <= $Num_Pages; $i++) {
                        if ($i != $Page) {
                            echo "<a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtKeyword=&$_GET[txtKeyword]'>$i</a>";
                        } else {
                            echo "<b>$i</b>";
                        }
                    }
                    if ($Page != $Num_Pages) {
                        echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtKeyword=$_GET[txtKeyword]'>Next>></a> ";
                    
                    }
//-----------------------------------------------------------

                    mysql_close($objConnect);
                    ?>

                    </body>
                    </html>




Tag : PHP, MySQL









ประวัติการแก้ไข
2013-10-01 01:45:02
2013-10-01 01:48:27
Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-10-01 00:56:11 By : memoryexp View : 552 Reply : 2
 

 

No. 1



โพสกระทู้ ( 1,439 )
บทความ ( 0 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Facebook

Code (PHP)
                  if ($_GET["Page"]<1) {
                        $Page = 1;
                    }

                    $Prev_Page = $Page - 1;
                    $Next_Page = $Page + 1;

                    $Page_Start = $Per_Page * ( $Page-1);







แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-10-01 01:48:10 By : xbeginner01
 


 

No. 2



โพสกระทู้ ( 7 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุณคับ

เจอแล้ว เส้นผมบังภูเขา


ประวัติการแก้ไข
2013-10-01 02:25:57
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-10-01 02:25:28 By : memoryexp
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยด้วยคับ พยายามหลายวันแล้ว You have an error in your SQL syntax; check the manual that corresponds to your
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 03
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่