Hello, good afternoon, I need to pass a value from mysql to input (text box), I am doing it in the following way but it throws me the following error:
$conexion=mysqli_connect($nombre_host,$nombre_usuario,$contrasena_usuario,$nombre_bd);
$consulta="SELECT * FROM clientes WHERE cedula='08522002'";
$resultados=mysqli_query($conexion,$consulta);
$fila=mysqli_fetch_row($resultados);
echo "<script type='text/javascript'>
document.getElementById('nombre_cliente').value =" . $fila[1] . "</script>";
}
Apart from the fact that the code seems to be quite poorly organized haha, the error it is throwing is because when interpreted it looks like this:
Where Javascript is expecting Brayan to be the name of a variable and not a string.
Try to do the following:
It should work that way. Greetings.
It's because by putting $row[1] you are not putting it in quotes and that makes javascript interpret it as a variable. And since that variable Brayan is not defined, it throws the error.
You would have to change this:
for something like:
either
I haven't tested the code so there may be bugs, but that's the bug.