รบกวนช่วยหน่อยค่ะ อัพโปรแกรมขึ้น server แล้วตารางแสดงข้อมูลไม่ขึ้น

สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network

Moderator: mindphp, ผู้ดูแลกระดาน

moomai
PHP Super Hero Member
PHP Super Hero Member
โพสต์: 680
ลงทะเบียนเมื่อ: 07/12/2016 10:54 am

รบกวนช่วยหน่อยค่ะ อัพโปรแกรมขึ้น server แล้วตารางแสดงข้อมูลไม่ขึ้น

โพสต์ที่ยังไม่ได้อ่าน โดย moomai »

รบกวนช่วยหน่อยค่ะ อัพโปรแกรมขึ้น server แล้วตารางแสดงข้อมูลไม่ขึ้นค่ะ แต่ตอนทำใน Localhost ไม่มีปัญหาอะไรค่ะ
อยากทราบว่าผิดที่ไหน ต้องแก้ยังไง

โค้ดที่ใช้

โค้ด: เลือกทั้งหมด

<?php
require_once'conn.php';
include '../header.php';

$sql = "SELECT * FROM $dataip ORDER BY id desc Limit 10";
$result = mysql_query($sql);

?>

<meta charset="UTF-8">
<title>Index_IP</title>
<link rel="stylesheet" href="css/m.css">

<ol class="breadcrumb">     
    <li role="presentation"><a href="#"><i class="glyphicon glyphicon-cog"></i> Tools</a></li>
    <li role="presentation" class="active"><a href="index.php"><i class="glyphicon glyphicon-file"></i> Index</a></li>          
</ol>

<form method="post" action="" name="from">
    <?php
    date_default_timezone_set("Asia/Bangkok");
    $time = time();
    $ip = $_SERVER["REMOTE_ADDR"];
    $xml_value = file_get_contents('http://freegeoip.net/xml/' . $ip);

    $result_xml = simplexml_load_string($xml_value);
    // print '<pre>';
    // var_dump($result_xml);
    // print '</pre>';
    $ip = $result_xml->IP;
    $countrycode = $result_xml->CountryCode[0];
    $countryname = $result_xml->CountryName[0];
    $regioncode = $result_xml->RegionCode[0];
    $regionname = $result_xml->RegionName[0];
    $city = $result_xml->City[0];
    $zipcode = $result_xml->ZipCode[0];
    $timezone = $result_xml->TimeZone[0];
    $latitude = $result_xml->Latitude[0];
    $longitude = $result_xml->Longitude[0];
    $metrocode = $result_xml->MetroCode[0];
    ?>
    <div class="content">
        <div class="well well-lg">
            <div align="center">
                <h3>หมายเลข IP Address ของคุณคือ </h3><br><br>
                <button type="button" class="btn btn-default btn-lg"><h2><?php echo $ip; ?></h2></button><br>
            </div><br><br>

            <table id="table-listtax" class="table table-striped">
                <tr>
                    <td align="right"><?php echo "<b>เวลาเข้าใช้งาน </b>"; ?></td>
                    <td><?php echo date(" H:i:s / D-m-y", time()); ?></td>
                </tr>
                <tr>
                    <td align="right"><?php echo "<b>พื้นที่ </b>"; ?></td>
                    <td><?php echo $timezone; ?></td>
                </tr>				
                <tr>
                    <td align="right"><?php echo "<b>ประเทศ </b>"; ?></td>
                    <td><?php echo $countryname . " (" . $countrycode . ")"; ?></td>
                </tr>
                <tr>
                    <td align="right"><?php echo "<b>เมือง </b>"; ?></td>
                    <td><?php echo $city; ?></td>
                </tr>
                <tr>
                    <td align="right"><?php echo "<b>ละติจูด </b>"; ?></td>
                    <td><?php echo $latitude; ?></td>
                </tr>
                <tr>
                    <td align="right"><?php echo "<b>ลองติจูด </b>"; ?></td>
                    <td><?php echo $longitude; ?></td>
                </tr>	
                <tr>			
                    <td colspan="2" class="text-center">
                        <div id="map" style="width:60%;height:400px;margin:5px auto;"></div>					
                    </td>
                </tr>					
            </table>
            <script>
                function myMap() {

                    var myLatLng = {lat: <?php echo $latitude . ', lng: ' . $longitude; ?>};

                    var map = new google.maps.Map(document.getElementById('map'), {
                        zoom: 10,
                        center: myLatLng
                    });

                    var marker = new google.maps.Marker({
                        position: myLatLng,
                        map: map,
                        title: '<?php echo $ip; ?>'
                    });
                }
            </script>
            <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDbNSR1qiV-_C8Sa978tiHmJ_ALSAy_Xt4&callback=myMap"></script>
        </div>

        <div class="well well-lg">
            <h3>IP Address</h3>
            <FONT SIZE=3>
                <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;            
                <b>IP Address</b> ย่อมาจากคำเต็มว่า " <i>Internet Protocal Address</i> " คือ หมายเลขประจำเครื่องคอมพิวเตอร์แต่ละเครื่องในระบบเครือข่ายที่ใช้โปรโตคอลแบบ TCP/IP ถ้าเปรียบเทียบก็คือบ้านเลขที่ของเรานั่นเอง ในระบบเครือข่าย จำเป็นจะต้องมีหมายเลข IP กำหนดไว้ให้กับคอมพิวเตอร์ และอุปกรณ์อื่นๆ ที่ต้องการ IP ทั้งนี้เวลามีการโอนย้ายข้อมูล หรือสั่งงานใดๆ จะสามารถทราบตำแหน่งของเครื่องที่เราต้องการส่งข้อมูลไป จะได้ไม่ผิดพลาดเวลาส่งข้อมูล ซึ่งประกอบด้วยตัวเลข 4 ชุด มีเครื่องหมายจุดขั้นระหว่างชุด  เช่น 192.168.100.1 หรือ 172.16.10.1  เป็นต้น  โดยหมายเลข IP Address ของเครื่องคอมพิวเตอร์แต่ละเครื่องจะมีค่าไม่ซ้ำกัน สิ่งตัวเลข 4 ชุดนี้บอก คือ Network ID กับ Host ID ซึ่งจะบอกให้รู้ว่า เครื่อง Computer ของเราอยู่ใน Network ไหน และเป็นเครื่องไหนใน network นั้น เราจะรู้ได้อย่างไรว่า Network ID และ Host ID มีค่าเท่าไหร่ ก็ขึ้นอยู่กับว่า IP Address นั้น อยู่ใน class อะไร</p>            
                <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                เหตุที่ต้องมีการแบ่ง class ก็เพื่อให้เกิดความเป็นระเบียบ เป็นการแบ่ง IP Address ออกเป็นหมวดหมู่นั้นเอง สิ่งที่จะเป็นตัวจำแนก class ของ network ก็คือ bit ทางซ้ายมือสุดของตัวเลขตัวแรกของ IP Address (ที่แปลงเป็นเลขฐาน 2 แล้ว) นั่นเอง โดยที่ถ้า bit ทางซ้ายมือสุดเป็น 0 ก็จะเป็น class A ถ้าเป็น 10 ก็จะเป็น class B ถ้าเป็น 110 ก็จะเป็น class C ดังนั้น IP Address จะอยู่ใน class A ถ้าตัวเลขตัวแรกมีค่าได้ตั้งแต่ 0 ? 127 (000000002 ? 011111112) จะอยู่ใน class B ถ้าเลขตัวแรกมีค่าตั้งแต่ 128 ? 191 (100000002 ? 101111112) และ จะอยู่ใน class C ถ้าเลขตัวแรกมีค่าตั้งแต่ 192 - 223 (110000002 ? 110111112) มีข้อยกเว้นอยู่นิดหน่อยก็คือตัวเลข 0, 127 จะใช้ในความหมายพิเศษ จะไม่ใช้เป็น address ของ network ดังนั้น network ใน class A จะมีค่าตัวเลขตัวแรก ในช่วง 1 ? 126
                </p>
                <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                สำหรับตัวเลขตั้งแต่ 224 ขึ้นไป จะเป็น class พิเศษ  อย่างเช่น  Class D ซึ่งถูกใช้สำหรับการส่งข้อมูลแบบ Multicast ของบาง Application และ Class E ซึ่ง Class นี้เป็น Address ที่ถูกสงวนไว้ก่อน ยังไม่ถูกใช้งานจริง ๆ  โดย Class D และ Class E นี้เป็น Class พิเศษ ซึ่งไม่ได้ถูกนำมาใช้งานในภาวะปกติ</p> 
                <p><b><u>ตัวอย่าง IP Address</u></b><br>
                - Class A ตั้งแต่ 10.***.***.*** 	<br>
                - Class B ตั้งแต่ 172.16.***.*** ถึง 172.31.***.*** <br>
                - Class C ตั้งแต่ 192.168.0.*** ถึง 192.168.255.*** </p>
                <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                จาก IP Address เราสามารถที่จะบอก ได้คร่าวๆ ว่า computer 2 เครื่องอยู่ใน network วงเดียวกันหรือเปล่าโดยการเปรียบเทียบ Network ID ของ IP Address ถ้ามี Network ID ตรงกันก็แสดงว่าอยู่ใน network วงเดียวกัน เช่น computer เครื่องหนึ่งมี IP Address 1.2.3.4 จะอยู่ใน network วงเดียวกับอีกเครื่องหนึ่งซึ่งมี IP Address 1.100.150.200 เนื่องจากมี Network ID ตรงกันคือ 1 (class A ใช้ Network ID 1 byte)</p>
            </FONT>    
        </div>
        <?php
        $sql = "INSERT INTO $dataip (ip, country_code, country_name, region_code, region_name, city,zipcode, timezone, latitude, longitude, metro_code, add_time)" . "VALUES ('$ip', '$countrycode', '$countryname', '$regioncode', '$regionname', '$city', '$zipcode', '$timezone', '$latitude', '$longitude', '$metrocode', '$time')";
            // echo $sql;
            mysql_query($sql) or die('*** ไม่สามารถบันทึกข้อมูลได้ ***');

        // echo $IP.'<br>'.$CountryCode.'<br>'.$CountryName.'<br>'.$RegionCode.'<br>'
        // .$RegionName.'<br>'.$City;
        ?>

        <div class="well well-lg">
            <h3 align="center">ข้อมูลการเข้าใช้งานล่าสุด</h3><br>
            <div class="row" align="center">
                <div class="col-md-12">
                    <div class="scroll1">
                        <table id="table-listtax" class="table table-striped">
                            <tr>
                                <th bgcolor="#8c8cd9"><p align="center">ลำดับ</p></th>
                                <th bgcolor="#8c8cd9"><p align="center">หมายเลข<br>IP Address</p></th>		
                                <th bgcolor="#8c8cd9"><p align="center">เวลาเข้าใช้งาน</p></th>
                                <th bgcolor="#8c8cd9"><p align="center">พื้นที่</p></th>
                                <th bgcolor="#8c8cd9"><p align="center">ประเทศ</p></th>
                                <th bgcolor="#8c8cd9"><p align="center">เมือง</p></th>
                                <th bgcolor="#8c8cd9"><p align="center">ละติจูด</p></th>
                                <th bgcolor="#8c8cd9"><p align="center">ลองติจูด</p></th>
                                <th bgcolor="#8c8cd9"><p align="center">แสดงข้อมูล</p></th>
                            </tr>
                            <?php
                            while ($fetch = mysql_fetch_assoc($result)) {
                                ?>
                                <tr>
                                    <td align="center"><?php echo $fetch['id']; ?></td>
                                    <td align="center"><?php echo $fetch['ip']; ?></td>
                                    <td align="center"><?php date_default_timezone_set("Asia/Bangkok");
                            echo (date(" H:i:s / D-m-y ", $fetch['add_time']));
                            ?></td>
                                    <td align="center"><?php echo $fetch['timezone']; ?></td>				
                                    <td align="center"><?php echo $fetch['country_name'] . " (" . $fetch['country_code'] . ")"; ?></td>	
                                    <td align="center"><?php echo $fetch['city']; ?></td>	
                                    <td align="center"><?php echo $fetch['latitude']; ?></td>
                                    <td align="center"><?php echo $fetch['longitude']; ?></td>

                                    <td align="center">
                                        <a href="showip.php?id=<?php echo $fetch['id']; ?>">
                                            <button type="button" class="btn btn-primary"><i class="glyphicon glyphicon-new-window"></i></button>
                                        </a>
                                    </td>
                                </tr>
                                <?php
                            }
                            ?>
                        </table>					
                    </div>

                </div>
                <div class="col-md-12 " align="center">
                    <input type="button" class="btn btn-primary" onclick="window.location = 'listip.php';" value="ดูข้อมูลเพิ่มเติม">
                </div>
            </div>		
        </div>	
    </div>
</form>
<?php 
include '../footer.php'; 						
Error ที่แสดงขึ้นค่ะ
Capture.PNG
ผลที่ได้ตอนรันบน localhost
Capture1.PNG
Capture1.PNG (106.94 KiB) Viewed 357 times
The truth is not as elegant as the idea.
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 113