I am working on a code that publishes articles on a page. This code works perfectly when creating the article, however, when trying to update it (publishing the same article with the same name but with different content from my admin panel), it is not updated. I search in the database and the info is the same (the changes that should be made in the UPDATE of the code have no effect) and when opening the article from the browser, it appears the same as before. Can you help me find the error, please?
PHP Code
//Crear archivo html del artículo
$nombreDelArchivo = url_amigable($titulo); //mando el título del artículo a una función que me hace el nombre en "formato" url amigable (para que no haya problemas al abrir el artículo desde el navegador
require_once("../includes/crearHTMLdeArticulo1.php");
require_once("../includes/crearHTMLdeArticulo2.php");
require_once("../includes/crearHTMLdeArticulo3.php");
$contenidoArt = $contenido1 . "<title>" . $titulo . " - Level Up</title>" . $contenido2 . '
<article id="contenedorArticuloCompleto">
<h1 id="tituloArtComp">' . $titulo . '</h1>
<div style="background-image:' . $foto . ';" id="imgArtComp"></div>
<div id="contenidoArtComp">' . $contenido . '</div>
</article>
' . $contenido3;
//Hasta acá es una mezcla entre html y php para armar el contenido de la página
$ruta = "../articles/" . $nombreDelArchivo . ".php";
if (file_exists($ruta)){ //Acá debería entrar si la ruta recién formada (conformada por ubicación del archivo y el nombre del mismo) es igual a alguna existente
$query1 = "UPDATE articles SET titulo = '$titulo', img = '$foto', descripcion = '$descripcion', contenido = '$contenido' WHERE titulo = '$titulo'";
if($resp1 = mysql_query($conexion, $query1)){
$archivo = fopen($ruta, "w");
fputs ($archivo, $contenidoArt);
fclose ($archivo);
$ok = true; //Pongo el valor "true" a la variable "ok" creada al inicio del código que tenía el valor predeterminado de "false"
echo $ok;
}else{
echo $ok;
}
}else{
$query2 = "INSERT INTO articles (titulo, img, descripcion, contenido) VALUES ('$titulo', '$foto', '$descripcion', '$contenido')";
if($resp2 = mysqli_query($conexion, $query2)){
$archivo = fopen($ruta, "w");
fputs ($archivo, $contenidoArt);
fclose ($archivo);
$ok = true;
echo $ok;
}else{
echo $ok;
}