• 05-03-2019, 20:22:52
    #1
    Üyeliği durduruldu
    arkadaşlar alttaki kodu çalıştırınca boyle bir hata alıyorum

    <?php
    $servername = "localhost";
    $username = "root";
    $password = "";
    $dbname = "optikler";
     
    // bağlantı oluşturuyoruz
    $conn = new mysqli($servername, $username, $password, $dbname);
     
    $sql = "SELECT * FROM oc_product_description";
    $result = $conn->query($sql);
    ?>
     
    <?php header('Content-type: application/xml; ',true);  ?>
    
    
     
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
     
    <?php while($row = $result->fetch_assoc()) { ?>
     
        <url>
            <link><?php echo ''.$row["name"]; ?></link>
            <changefreq>weekly</changefreq>
            <priority>0.7</priority>
        </url>
     
    <?php } ?>
     
     
     
    </urlset>
    aldıgım hata sanırsam türkçe karakterde sorun var yardımlarınızı bekliyorm
  • 05-03-2019, 20:35:28
    #2
    Sql verilerini çekerken başlığı çekmişssiniz hocam, url'lerini cekmeniz gerekiyordu
  • 05-03-2019, 20:37:54
    #3
    Üyeliği durduruldu
    aynı hocam ondan deilde türkçe karakterlerde soru var galiba
  • 06-03-2019, 16:24:57
    #4
    1- PHP tagını böyle başlat
    <?php ob_start();header('Content-Type: text/xml'); //PHP dosyasının XML dosyası olarak algılanmasını sağlıyoruz.
    2- Bunu sil
    <?php header('Content-type: application/xml; ',true); ?>
    3- bunu sil
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
    4- 3. madde yerine bunu ekle
    <?
    echo '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">
    '; ?>
    5- $sql = "SELECT * FROM oc_product_description";
    üstüne mysql_query("SET NAMES UTF8"); bunu ekle (karakter setin UTf-8 ise)