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?

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>";



Options: ReplyQuote

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

Sorry, you can't reply to this topic. It has been closed.

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.