Menu
Hello, I am in a problem and it is that it appears to me that I have indefinite id , I have actually been able to solve it. I give you my code waiting for advice. Thank you
<i>
</i><?php
ini_set('display_errors', true);
error_reporting(E_ALL);
if(empty($_GET['id'])) {
die("<pre>ERROR: 'id' not set.</pre>");
}
$consulta = ConsultarCuenta($_GET['id']);
if($consulta == false) {
die("<pre>Nothing returned by query</pre>");
}
function ConsultarCuenta($id)
{
require 'conexion.php'; // it's not optional, so <span><code>require</code></span> it
$sentencia = "SELECT * FROM cuenta WHERE id='$id'";
$resultado = $conexion->query($sentencia);
if($resultado == false) {
die("<pre>QUERY ERROR:n".print_r($conexion->errorInfo(), true)."nQuery:n$$sentencia</pre>");
}
$fila = $resultado->fetch(PDO::FETCH_ASSOC);
return $fila;
}
cuenta.id
<i>
</i>function ConsultarCuenta($id)
{
require 'conexion.php'; // it's not optional, so <span><code>require</code></span> it
$sentencia = "SELECT * FROM cuenta WHERE id = :id";
$stmt = $conexion->prepare($sentencia);
if($stmt == false) {
die("<pre>INVALID QUERY:n".print_r($conexion->errorInfo())."nSQL:n$sentencia</pre>");
}
$resultado = $stmt->execute($stmt, array('id' => $id));
if($resultado == false) {
die("<pre>QUERY ERROR:n".print_r($stmt->errorInfo(), true)."nQuery:n$$sentencia</pre>");
}
$fila = $resultado->fetch(PDO::FETCH_ASSOC);
return $fila;
}
<?php
ini_set('display_errors', true);<br/>
error_reporting(E_ALL);
if(empty($_GET['id'])) {<br/>
die("<pre>ERROR: 'id' not set.</pre>");<br/>
}
$consulta = ConsultarCuenta($_GET['id']);<br/>
if($consulta == false) {<br/>
die("<pre>Nothing returned by query</pre>");<br/>
}
function ConsultarCuenta($id)<br/>
{<br/>
require 'conexion.php'; // it's not optional, so <C>
require</C> it<br/>
$sentencia = "SELECT * FROM cuenta WHERE id='$id'";<br/>
$resultado = $conexion->query($sentencia);<br/>
if($resultado == false) {<br/>
die("<pre>QUERY ERROR:n".print_r($conexion->errorInfo(), true)."nQuery:n$$sentencia</pre>");<br/>
}<br/>
$fila = $resultado->fetch(PDO::FETCH_ASSOC);<br/>
return $fila;<br/>
}<br/>
?>
>@NogDog#1616634
require
Id de Cuenta<input type="text" name="cuenta" value="<?php echo $consulta[1]; ?>" placeholder="id de cuenta">
<?php if (!empty($errores)): ?><br/>
<div class="alert error"><br/>
<?php echo $errores; ?> <br/>
</div><br/>
<?php endif ?>
<i> </i><CODE></div>
<i> </i> <?php if (!empty($succes)):?>
<i> </i> <div class="alert succes">
<i> </i> <?php echo $succes;?>
<i> </i> </div>
<i> </i> <?php endif ?></CODE>
<i> </i>
<input type="hidden" id="id" name="id" value="<?php echo $id; ?>">
0.1.9 — BETA 5.4