Hi everyone,
I have read for a while about this, but I have some problems with the sitemap.php generated with PHP and the process I have to follow.
The code I use to create the sitemap is the following:
<?php
header('Content-type: application/xml');
echo "<?xml version='1.0' encoding='UTF-8'?>";
echo "<urlset xmlns='http://www.sitemaps.org/schemas/sitemap/0.9'
xmlns:news='http://www.google.com/schemas/sitemap-news/0.9'>";
require 'admin/config.php';
require 'funciones.php';
try {
$conexion = new PDO($bd_config['dbname'], $bd_config['usuario'], $bd_config['password'] );
} catch (PDOException $e) {
header ('Location: error.php');
echo "ERROR: ".$e->getMessage();
die();
}
$hoy = getdate();
$fecha_hoy = $hoy['year'] . "-" . $hoy['mon'] . "-" . $hoy['mday'];
echo "<url>";
echo "<loc>http://www.laxtore.com/</loc>";
echo "<lastmod>" . $fecha_hoy . "</lastmod>";
echo "<changefreq>daily</changefreq>";
echo "<priority>1</priority>";
echo "</url>";
echo "<url>";
echo "<loc>http://www.laxtore.com/Juegos/Indice-Precios/</loc>";
echo "<lastmod>" . $fecha_hoy . "</lastmod>";
echo "<changefreq>daily</changefreq>";
echo "<priority>1</priority>";
echo "</url>";
echo "<url>";
echo "<loc>http://www.laxtore.com/contacto/</loc>";
echo "<priority>0.8</priority>";
echo "</url>";
echo "<url>";
echo "<loc>http://www.laxtore.com/Juegos/Xbox-One/</loc>";
echo "<lastmod>" . $fecha_hoy . "</lastmod>";
echo "<changefreq>daily</changefreq>";
echo "<priority>1</priority>";
echo "</url>";
$statement = $conexion->prepare("SELECT * FROM retrocompatibles_360 ORDER BY Agregado DESC");
$statement->execute();
$ultimo_juego_360 = $statement->fetchAll();
echo "<url>";
echo "<loc>http://www.laxtore.com/Juegos/Xbox-360/</loc>";
echo "<lastmod>" . substr($ultimo_juego_360[0]['Agregado'],0,10) . "</lastmod>";
echo "<changefreq>daily</changefreq>";
echo "<priority>1</priority>";
echo "</url>";
$statement = $conexion->prepare("SELECT * FROM retrocompatibles_360 WHERE retro = 1 ORDER BY Agregado DESC");
$statement->execute();
$ultimo_juego_360_retro = $statement->fetchAll();
echo "<url>";
echo "<loc>http://www.laxtore.com/Juegos/Xbox-One/retrocompatibles/</loc>";
echo "<lastmod>" . substr($ultimo_juego_360_retro[0]['Agregado'],0,10) . "</lastmod>";
echo "<changefreq>monthly</changefreq>";
echo "<priority>1</priority>";
echo "</url>";
echo "<url>";
echo "<loc>http://www.laxtore.com/Juegos/Deals-With-Gold/</loc>";
echo "<changefreq>weekly</changefreq>";
echo "<priority>1</priority>";
echo "</url>";
$statement = $conexion->prepare("SELECT * FROM art ORDER BY fecha_publicacion");
$statement->execute();
$articulos = $statement->fetchAll();
foreach ($articulos as $articulo) {
echo "<url>";
echo "<loc>http://www.laXtore.com/noticia/" . $articulo['ID'] . "/" . limpia_url($articulo['titulo']) . "/</loc>";
echo "<news:news>";
echo "<news:publication>";
echo "<news:name>LaXtore</news:name>";
echo "<news:language>es</news:language>";
echo "</news:publication>";
echo "<news:genres>TecnologĂa, Xbox One, videojuegos, videogames</news:genres>";
echo "<news:publication_date>" . substr($articulo['fecha_publicacion'],0,10) . "</news:publication_date>";
echo "<news:title>" . $articulo['titulo'] . "</news:title>";
echo "<news:keywords>" . str_replace(",", ";",$articulo['etiquetas']) . "</news:keywords>";
echo "</news:news>";
echo "</url>";
}
$statement = $conexion->prepare("SELECT * FROM info_XboxOne ORDER BY agregado DESC");
$statement->execute();
while ($xbox_individual = $statement->fetch()) {
echo "<url>";
echo "<loc>http://www.laxtore.com/Juegos/Xbox-One/" . $xbox_individual['id'] . "/" . limpia_url($xbox_individual['Juego']) . "/</loc>";
echo "<lastmod>" . substr($xbox_individual['agregado'],0,10) . "</lastmod>";
echo "<priority>0.8</priority>";
echo "</url>";
}
echo "</urlset>";
?>
I try validating the sitemap.php file here: https://webmaster.yandex.com/tools/sitemap/?tab=url&sitemapUrl=www.laXtore.com%2Fsitemap.php
I have several errors but I don’t know how to fix them. Also the last part of the code is not shown also.
I would appreciate some kind of help.