/    Sign up×
Community /Pin to ProfileBookmark

no me funciona, porque?

__(Added `[code]…[/code]` tags ~ MOD)__

[code]
<?php
$consulta = ConsultarCuenta($_GET[‘id’]);
function ConsultarCuenta($idCuenta){
include ‘conexion.php’;
$sentencia =”SELECT * FROM cuenta WHERE id='”.$idCuenta.”‘”;
$resultado = $conexion->query($sentencia);
$fila = $resultado->FETCH_ASSOC();
return[
$fila[‘id_cuenta’],
$fila[‘fecha_de_pago’],
$fila[‘fecha_de_vencimiento de pago’],
$fila[‘valor_a_pagar’],
$fila[‘periodo_de_cuenta’],
$fila[‘estado_de_cuenta’],
$fila[‘registro_de_residente’]

];
}

?><?php
$consulta = ConsultarCuenta($_GET[‘id’]);
function ConsultarCuenta($idCuenta){
include ‘conexion.php’;
$sentencia =”SELECT * FROM cuenta WHERE id='”.$idCuenta.”‘”;
$resultado = $conexion->query($sentencia);
$fila = $resultado->FETCH_ASSOC();
return[
$fila[‘id_cuenta’],
$fila[‘fecha_de_pago’],
$fila[‘fecha_de_vencimiento de pago’],
$fila[‘valor_a_pagar’],
$fila[‘periodo_de_cuenta’],
$fila[‘estado_de_cuenta’],
$fila[‘registro_de_residente’]

];
}

?>
[/code]

to post a comment
PHP

22 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmMar 22.2020 — Do you have an error code/message?

Why the double post of the same code?

Why not just return $fila?

return $fila;
Copy linkTweet thisAlerts:
@NogDogMar 22.2020 — If it is not working, try getting any warnings/notices/errors:
<i>
</i>&lt;?php
ini_set('display_errors', true);
error_reporting(E_ALL);

$consulta = ConsultarCuenta($_GET['id']);
function ConsultarCuenta($idCuenta){
include 'conexion.php';
$sentencia ="SELECT * FROM cuenta WHERE id='".$idCuenta."'";
$resultado = $conexion-&gt;query($sentencia);
$fila = $resultado-&gt;FETCH_ASSOC();
return[
$fila['id_cuenta'],
$fila['fecha_de_pago'],
$fila['fecha_de_vencimiento de pago'],
$fila['valor_a_pagar'],
$fila['periodo_de_cuenta'],
$fila['estado_de_cuenta'],
$fila['registro_de_residente']
];
}
Copy linkTweet thisAlerts:
@jdvdauthorMar 23.2020 — hola

sale este error


Error fatal : Error no detectado: Llamada al método indefinido PDOStatement :: FETCH_ASSOC () en C: xampp htdocs Proyecto html cuentas consultar_c gestionar modificar.php: 10 Stack trace: # 0 C: xampp htdocs Proyecto html cuentas consultar_c gestionar modificar.php (5): ConsultarCuenta ('1') # 1 {main} arrojado en C: xampp htdocs Proyecto html cuentas consultar_c gestionar modificar. PHP en la línea 10
Copy linkTweet thisAlerts:
@jdvdauthorMar 23.2020 — ya agregue el codigo que dejaste y salio eso
Copy linkTweet thisAlerts:
@ginerjmMar 23.2020 — no speaka spanish

Maybe you can pass along any error message in English? Or tell us in English what the problem is?
Copy linkTweet thisAlerts:
@jdvdauthorMar 23.2020 — Fatal error: Uncaught Error: Call to undefined method PDOStatement::FETCH_ASSOC() in C:xampphtdocsProyectohtmlcuentasconsultar_cgestionarmodificar.php:10 Stack trace: #0 C:xampphtdocsProyectohtmlcuentasconsultar_cgestionarmodificar.php(5): ConsultarCuenta('1') #1 {main} thrown in C:xampphtdocsProyectohtmlcuentasconsultar_cgestionarmodificar.php on line 10
Copy linkTweet thisAlerts:
@ginerjmMar 23.2020 — So you have not made the connection perhaps? Or you aren't using PDO properly?

Show us the code NEATLY
Copy linkTweet thisAlerts:
@jdvdauthorMar 23.2020 — <?php

ini_set('display_errors', true);

error_reporting(E_ALL);

$consulta = ConsultarCuenta($_GET['id']);

function ConsultarCuenta($idCuenta){

include 'conexion.php';

$sentencia ="SELECT * FROM cuenta WHERE id='".$idCuenta."'";

$resultado = $conexion->query($sentencia) or die ("error al consultar cuenta ". mysqli_error($conexion));

$fila = $resultado->fetch_assoc();

return [

$fila['id_cuenta'],

$fila['fecha_de_pago'],

$fila['fecha_de_vencimiento de pago'],

$fila['valor_a_pagar'],

$fila['periodo_de_cuenta'],

$fila['estado_de_cuenta'],

$fila['registro_de_residente']

];

}

?>
Copy linkTweet thisAlerts:
@ginerjmMar 23.2020 — Which line has the error? Where is the connection made? Why do you have a call to mysqli_error?
Copy linkTweet thisAlerts:
@jdvdauthorMar 23.2020 — tiene error en la linea 10

el mysqli era por pobrar una cosa

solo ignoralo,

ya lo quito
Copy linkTweet thisAlerts:
@ginerjmMar 23.2020 — Which line has the error? Where is the connection made? Why do you have a call to mysqli_error?

Apparently you are using PDO for the first time. Read the manual on the functions. There is no fetch_assoc
Copy linkTweet thisAlerts:
@ginerjmMar 23.2020 — IN ENGLISH please
Copy linkTweet thisAlerts:
@jdvdauthorMar 23.2020 — [upl-image-preview url=https://www.webdeveloper.com/assets/files/2020-03-23/1584989148-452268-problema.jpeg]
Copy linkTweet thisAlerts:
@jdvdauthorMar 23.2020 — entiendo

voy a cambiarlo
Copy linkTweet thisAlerts:
@ginerjmMar 23.2020 — CODE please. No pictures And how about answering my questions?
Copy linkTweet thisAlerts:
@jdvdauthorMar 23.2020 — as soon as I change it, I'll tell you I get out if
Copy linkTweet thisAlerts:
@jdvdauthorMar 23.2020 — has error line 10, the connection I'm calling it with the include code, and mysqli was calling it in case there was an error
Copy linkTweet thisAlerts:
@ginerjmMar 23.2020 — you can't mix mysqli and pdo. Use one only And read the manual
Copy linkTweet thisAlerts:
@NogDogMar 23.2020 — PDOStatement does not have a method by that name. You would instead use the fetch() method, and pass the class constant that says you want it as as associative array:
<i>
</i>$fila = $resultado-&gt;fetch(PDO::FETCH_ASSOC);
Copy linkTweet thisAlerts:
@jdvdauthorMar 23.2020 — thank you, it doesn't show me erorr but it doesn't change me I don't know why
Copy linkTweet thisAlerts:
@jdvdauthorMar 23.2020 — Thank you both for your help
Copy linkTweet thisAlerts:
@ginerjmMar 23.2020 — Good luck. You're not being very helpful.
×

Success!

Help @jdvd spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...