MySQL Forums
Forum List  »  Spanish

Pasar código de MYSQL a MYSQLI
Posted by: pablo Malit
Date: March 29, 2017 01:01PM

Buenas tengo este codigo en MYSQL!
Pero necesito pasarlo a MYSQLI para que el servidor no me de el tipico error: "Deprecated: mysql_connect(): The mysql extension is deprecated..."
Me pueden brindar una ayuda para entender como pasarlo?


<?php
class conexion{
function recuperarDatos(){
$host = "localhost";
$user = "root";
$pw = "";
$basededatos = "comentariostd";

$con = mysql_connect($host, $user, $pw) or die ("No se pudo conectar a la base de datos");
mysql_select_db($basededatos, $con) or die ("No se encontro la base de datos");
$query = "SELECT * FROM comentariostabla";
$resultado = mysql_query($query);

while ($fila = mysql_fetch_array($resultado)) {
echo "Nombre: <br> ";
echo "$fila[nombre] <br> ";
echo "<br>";
echo "Lugar: <br> ";
echo "$fila[lugar]<br> ";
echo "<br>";
echo "Comentario: <br> ";
echo "$fila[comentario] <br> ";
echo "<br>";

}
}
}
?>

Saludooooooos!

Options: ReplyQuote


Subject
Views
Written By
Posted
Pasar código de MYSQL a MYSQLI
200
March 29, 2017 01:01PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.