0

Tengo el siguiente codigo:

**<?php
$id = @$_POST['id'];
$con = mysqli_connect("localhost","root","","test2");
mysqli_set_charset($con, "utf8");
$sql = "SELECT * FROM usuario WHERE id = $id ";
$result = mysqli_query($con,$sql) or die ("Problema al insertar".mysqli_error());
$rs = mysqli_fetch_array($result,MYSQLI_NUM);
$json[] = $rs;
echo json_encode($json, JSON_UNESCAPED_UNICODE);
mysqli_free_result($result);
mysqli_close($con);
?>**

El error que me aparece es: Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\xampp\htdocs\mysqlcrud2\desc.php on line 10 Problema al insertar

Que es lo que estoy haciendo mal?

1 respuesta 1

0

Tienes que pasarle como parámetro el link de conexión (donde figura entre otros, la información sobre el error).

$result = mysqli_query($con,$sql) or die ("Problema al insertar".mysqli_error($con));
1
  • gracias! lo corregi y ahora me aparece esto: Problema al insertarYou have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1 .
    – ari127
    el 13 sep. 2020 a las 19:43

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.