Fatal error: Uncaught Error: Call to undefined function mysql_connect ()

0

I would like you to help me solve this problem, the following error appears on a page I am designing

Fatal error: Uncaught Error: Call to undefined function mysql_connect () in G: \ Pagina \ comentarios.php: 11 Stack trace: # 0 G: \ Pagina \ Sugerencias.php (320): include () # 1 { main} thrown in G: \ Pagina \ comentarios.php on line 11 Since I do not know much about programming, I'm following the steps indicated on a page: link

comments.php code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Comentarios</title>
</head>
<body>
<?php
  // Se conecta al SGBD
  if(!($conexion = mysql_connect("localhost", "root", "")))
    die("Error: No se pudo conectar");

  // Selecciona la base de datos
  if(!mysql_select_db("comentarios", $conexion))
    die("Error: No existe la base de datos");

  // Sentencia SQL: muestra todo el contenido de la tabla "books"
  $sentencia = "SELECT * FROM comentarios";
  // Ejecuta la sentencia SQL
  $resultado = mysql_query($sentencia, $conexion);
  if(!$resultado)
    die("Error: no se pudo realizar la consulta");

 echo "<div id='comentarios'>";
  while($fila = mysql_fetch_assoc($resultado))
  {
   echo "<div class='user'>";
    echo "<a href='" . $fila['website'] . "'>" . $fila['usuario'] . "</a><br/> <div class='tiempo'>" . $fila['fecha'] . "</div>";
   echo "</div>";
   echo "<div class='comment'>";
    echo $fila['comentario'] . '<br/>';
   echo "</div>";
  }
 echo "</div><br/>";
  // Libera la memoria del resultado
  mysql_free_result($resultado);

  // Cierra la conexión con la base de datos
  mysql_close($conexion);
?>
</body>
</html>

I think it also has to do with this other file:

conexion.php

<?php
$conexion = mysqli_connect("localhost","root"," ","comentarios");

if (!$conexion) {
 die("Error de conexión (".mysqli_connect_errno().")".mysqli_connect_error());
}
?>

I attach the codes of the other files just in case

This is the code that goes on the page where I want to insert the comment box

</div>
<style type="text/css">
form ::-webkit-scrollbar {
    width: 8px;
}
form ::-webkit-scrollbar-button {
    background:#003;
}

form ::-webkit-scrollbar-track {
 background:#EEE;
}

form ::-webkit-scrollbar-thumb {
 background:#003;
}

form {
 clear:both;
 width:74%;
}
#datos {
 float:left;
}
input[type=text] {
 display:block;
 padding:9.4px 4px 9.3px 45px;
 font-family:"Raleway", Arial, Helvetica, sans-serif;
 font-size:18px;
 font-weight:300;
 border:#CCC 1px solid;
 color:#CCC;
 margin:9px 1px 9px 8px;
 transition:all ease-in-out .3s;
 clear:inherit;
}
input[type=text]:hover {
 color:#666;
 border:#666 1px solid;
 box-shadow:2px 2px 2px #EEE,-2px -2px 2px #EEE;

}
input[type=text].nombre {
 background:#FFF url(imagenes/user.png) no-repeat;
 border-radius:2px 18px 0px 2px;

}
input[type=text].email {
 background:#FFF url(imagenes/email.png) no-repeat;
}

input[type=text].website {
 background:#FFF url(imagenes/web.png) no-repeat;
 border-radius:2px 0px 0px 2px;

}

textarea.comentario {
 clear:both;
 width:444px;
 display:block;
 padding:8px 11px 8px 11px;
 font-family:"Raleway", Arial, Helvetica, sans-serif;
 font-size:18px;
 border:#CCC 1px solid;
 border-radius:18px 2px 2px 0px;
 color:#CCC;
 margin:9px 1px 9px 1px;
 transition:all ease-in-out .3s;
 float:left;
 resize:none;
}
textarea.comentario:hover {
 color:#666;
 box-shadow:2px 2px 2px #EEE,-2px -2px 2px #EEE;
 border:#666 1px solid;

}
input[type=submit] {
 width:99.4%;
 clear:both;
 background:#FFF;
 display:block;
 padding:8px 11px 8px 11px;
 font-family:"Raleway", Arial, Helvetica, sans-serif;
 font-size:18px;
 border:#CCC 1px solid;
 border-radius:0px 0px 18px 18px;
 color:#CCC;
 margin:9px 1px 9px 1px;
 transition:all ease-in-out .3s;

}
input[type=submit]:hover {
 color:#666;
 box-shadow:2px 2px 2px #EEE,-2px -2px 2px #EEE;
 border:#666 1px solid;

}
#comentarios {
 display:block;
 width:70%;
 padding:4px 4px 4px 12px;
 font-family:'Raleway',sans-serif;

}
#comentarios:hover {
}
#comentarios a {
 color:#FFF;
 text-decoration:none;
 transition:all ease-out .3s;

}
#comentarios a:hover {
 color:#EEE;
}

#comentarios .user {
 clear:both;
 padding:4px 9px 4px 9px;
 margin:4px 0px 4px 4px;
 float:left;
 width:30%;
 background:#003;
 border-radius:4px 0px 0px 4px;
 font-weight:bold;
 color:#FFF;

}
#comentarios .comment {
 border:1px solid #003;
 margin:4px 4px 4px 0px;
 padding:18px 9px 18px 9px;
 float:left;
 width:61%;
 border-radius:0px 4px 4px 0px;

}
#comentarios .comment a {
 transition:all ease-in .2s;
 color:#999;
}
#comentarios .comment img {
 width:93%;
 border:7px solid #FFF;
 box-shadow:2px 2px 4px #003;
}
#comentarios .comment a:hover {
 font-weight:bold;
}
.tiempo {
 text-align:right;
 text-transform:uppercase;
 font-size:10px;
}
</style>
</head>


<body>

<?php
include('comentarios.php');
?><br/><br/><br/>

send.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
</head>
<body>
<?php
// Llamamos al archivo de conexión a la base de datos
require("conexion.php");

//Creamos las variables con los nombres de los campos del formulario
$usuario = $_POST["usuario"];
$email = $_POST["email"];
$website = $_POST["website"];
$comentario = $_POST["comentario"];

// Codigo de insercion a la base de datos
$insertar = mysqli_query($conexion,"INSERT INTO comentarios (usuario, email, website, comentario) VALUES ('$usuario','$email','$website','$comentario')");

if (!$insertar) {
 echo "Error al guardar";
} else {
 echo "Guardado con éxito";
}

mysqli_close($conexion);
?>
<br/>
<a href="Sugerencias.php">ver comentarios</a>
</body>

</html>
    
asked by Nooob 04.11.2018 в 10:27
source

0 answers