• 03-07-2021, 17:04:38
    #1
    Dinamik sitemap yapmaya çalıştım. Bu hatayı aldım.




    hatayı nerede yaptım bana dinamik sitemapta biri yardım edebilir mi lütfen ?



    <?php
    $servername = "localhost";
    $username = "name";
    $password = "pass";
    $dbname = "dbname";
    // bağlantı oluşturuyoruz
    $conn = new mysqli($servername, $username, $password, $dbname);
    $sql = "SELECT * FROM posts ORDER BY tarih DESC"; // Veritabanı sorgusu
    $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>
    <loc><?php echo 'https://www.xxxx.net/'.$row["xxx_name"]; ?></loc>
    <!-- Veritabanı sütun adı -->
    <changefreq>daily</changefreq>
    <priority>0.7</priority>
    </url>
    <?php } ?>
    </urlset>
  • 03-07-2021, 17:24:57
    #2
    <?php
    header('Content-type: Application/xml; charset="utf8"', true);
    ?>
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xsi:schemaLocation=" http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">

    <?php
    $dbhost = "localhost"; //Veritabanın Bulunduğu Host
    $dbuser = "root"; //Veritabanı Kullanıcı Adı
    $dbpass = "sifre"; //Veritabanı Şifresi
    $dbdata = "veritabani"; //Veritabanı Adı

    try{
    $db = new PDO("mysql:host=".$dbhost."; dbname=".$dbdata."; charset=utf8mb4", "".$dbuser, "".$dbpass);
    }
    catch(PDOException $mesaj){
    echo $mesaj->getmessage();
    }

    $site = $_SERVER['HTTP_HOST'];
    $gun = date("Y-m-d");
    $saat = date('H:i:s');
    $tarih = $gun . "T" . $saat . "+00:00";
    ?>
    <?php
    $icerikler = $db->prepare("select * from icerikler");
    $icerikler->execute();
    ?>
    <?php
    while ($icerik = $icerikler ->fetch(PDO::FETCH_ASSOC)) {
    ?>
    <url>
    <loc>https://domain.com/<?php echo $icerik["sef"]; ?>/</loc>

    <lastmod><?php echo $tarih; ?></lastmod>
    <changefreq>daily</changefreq>
    <priority>1.00</priority>
    </url>
    <?php } ?>

    </urlset>


    Buyrun hocam bunu bu çalışıyor veritabanı ayarlarını ve tablo adlarını kendinize uyarlayabilirsiniz.
  • 03-07-2021, 17:28:00
    #3
    Misafir adlı üyeden alıntı: mesajı görüntüle
    <?php
    header('Content-type: Application/xml; charset="utf8"', true);
    ?>
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xsi:schemaLocation=" http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">

    <?php
    $dbhost = "localhost"; //Veritabanın Bulunduğu Host
    $dbuser = "root"; //Veritabanı Kullanıcı Adı
    $dbpass = "sifre"; //Veritabanı Şifresi
    $dbdata = "veritabani"; //Veritabanı Adı

    try{
    $db = new PDO("mysql:host=".$dbhost."; dbname=".$dbdata."; charset=utf8mb4", "".$dbuser, "".$dbpass);
    }
    catch(PDOException $mesaj){
    echo $mesaj->getmessage();
    }

    $site = $_SERVER['HTTP_HOST'];
    $gun = date("Y-m-d");
    $saat = date('H:i:s');
    $tarih = $gun . "T" . $saat . "+00:00";
    ?>
    <?php
    $icerikler = $db->prepare("select * from icerikler");
    $icerikler->execute();
    ?>
    <?php
    while ($icerik = $icerikler ->fetch(PDO::FETCH_ASSOC)) {
    ?>
    <url>
    <loc>https://domain.com/<?php echo $icerik["sef"]; ?>/</loc>

    <lastmod><?php echo $tarih; ?></lastmod>
    <changefreq>daily</changefreq>
    <priority>1.00</priority>
    </url>
    <?php } ?>

    </urlset>


    Buyrun hocam bunu bu çalışıyor veritabanı ayarlarını ve tablo adlarını kendinize uyarlayabilirsiniz.

    hocam tablolar hangisi oluyor bilgim çok azda söyler misiniz hangilerini değiştireyim
  • 03-07-2021, 17:39:00
    #4
    Misafir adlı üyeden alıntı: mesajı görüntüle
    <?php
    header('Content-type: Application/xml; charset="utf8"', true);
    ?>
    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xsi:schemaLocation=" http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">

    <?php
    $dbhost = "localhost"; //Veritabanın Bulunduğu Host
    $dbuser = "root"; //Veritabanı Kullanıcı Adı
    $dbpass = "sifre"; //Veritabanı Şifresi
    $dbdata = "veritabani"; //Veritabanı Adı

    try{
    $db = new PDO("mysql:host=".$dbhost."; dbname=".$dbdata."; charset=utf8mb4", "".$dbuser, "".$dbpass);
    }
    catch(PDOException $mesaj){
    echo $mesaj->getmessage();
    }

    $site = $_SERVER['HTTP_HOST'];
    $gun = date("Y-m-d");
    $saat = date('H:i:s');
    $tarih = $gun . "T" . $saat . "+00:00";
    ?>
    <?php
    $icerikler = $db->prepare("select * from icerikler");
    $icerikler->execute();
    ?>
    <?php
    while ($icerik = $icerikler ->fetch(PDO::FETCH_ASSOC)) {
    ?>
    <url>
    <loc>https://domain.com/<?php echo $icerik["sef"]; ?>/</loc>

    <lastmod><?php echo $tarih; ?></lastmod>
    <changefreq>daily</changefreq>
    <priority>1.00</priority>
    </url>
    <?php } ?>

    </urlset>


    Buyrun hocam bunu bu çalışıyor veritabanı ayarlarını ve tablo adlarını kendinize uyarlayabilirsiniz.


    çalıştı hocam teşekkürler ama ufak bir sıkıntım var şimdi ben linki sonunu doldururken boşluklar var onları - ye nasıl çevirebilirim ?