简体   繁体   English

BasicNetwork.performRequest:意外的响应代码500 Android

[英]BasicNetwork.performRequest: Unexpected response code 500 Android

I am trying to update parameters in my databas,e but in Android I am getting this error: 我正在尝试更新数据库中的参数,但是在Android中我收到此错误:

09-15 13:26:43.505 31109-31784/app.bsmo.ismael034.com.bsmo E/Volley: [27268] BasicNetwork.performRequest: Unexpected response code 500 for http://bsmo.000webhostapp.com/Asistencia/actualizar_meta.php?id=2 09-15 13:26:43.505 31109-31784 / app.bsmo.ismael034.com.bsmo E / Volley:[27268] BasicNetwork.performRequest: http ://bsmo.000webhostapp.com/Asistencia/actualizar_meta的意外响应代码500 .PHP?ID = 2

I think it`sa PHP problem, but I cannot find any error. 我认为这是一个PHP问题,但我找不到任何错误。 The server is active and full working. 服务器处于活动状态,并且可以正常工作。

Here is my code: 这是我的代码:

<?php
 require 'Database.php';

class Meta
{
    function __construct()
    {
    }

    public static function getAll()
    {
        $consulta = "SELECT * FROM asistencia";
        try {
            // Preparar sentencia
            $comando = Database::getInstance()->getDb()->prepare($consulta);
            // Ejecutar sentencia preparada
            $comando->execute();

            return $comando->fetchAll(PDO::FETCH_ASSOC);

        } catch (PDOException $e) {
            return false;
        }
    }

    public static function getById($id)
    {
        // Consulta de la meta
        $consulta = "SELECT id,
                             id_musico,
                             asistenciaD
                             FROM asistencia
                             WHERE id = ?";

        try {
            // Preparar sentencia
            $comando = Database::getInstance()->getDb()->prepare($consulta);
            // Ejecutar sentencia preparada
            $comando->execute(array($id));
            // Capturar primera fila del resultado
            $row = $comando->fetch(PDO::FETCH_ASSOC);
            return $row;

        } catch (PDOException $e) {
            // Aquí puedes clasificar el error dependiendo de la excepción
            // para presentarlo en la respuesta Json
            return -1;
        }
    }

    public static function update(
        $id,
        $id_musico,
        $asistenciaD 
    )
    {
        // Creando consulta UPDATE
        $consulta = "UPDATE asistencia" .
            " SET id_musico=?, asistenciaD=? " .
            "WHERE id=?";

        // Preparar la sentencia
        $cmd = Database::getInstance()->getDb()->prepare($consulta);

        // Relacionar y ejecutar la sentencia
        $cmd->execute(array($id_musico, $asistenciaD, $id));

        return $cmd;
    }

    public static function insert(
        $dia,
        $asistenciaD 
    )
    {
        // Sentencia INSERT
        $comando = "INSERT INTO asistencia ( " .
            "dia," .
            " asistenciaD)" .
            " VALUES( ?,?)";

        // Preparar la sentencia
        $sentencia = Database::getInstance()->getDb()->prepare($comando);

        return $sentencia->execute(
            array(
                $dia,
                $asistenciaD 
            )
        );

    } 
}
?>

actualizar_meta.php: actualizar_meta.php:

<?php

require 'Meta.php';

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    // Decodificando formato Json
    $body = json_decode(file_get_contents("php://input"), true);

    // Actualizar meta
    $retorno = Meta::update(
        $body['id'],
        $body['asistenciaD']);

    if ($retorno) {
        // Código de éxito
        print json_encode(
            array(
                'estado' => '1',
                'mensaje' => 'Actualización éxitosa')
        );
    } else {
        // Código de falla
        print json_encode(
            array(
                'estado' => '2',
                'mensaje' => 'Actualización fallida')
        );
    }
}

How to fix that? 如何解决? Thanks so much 非常感谢

Your code has a redundant , before FROM and after asistenciaD 您的代码冗余,FROMasistenciaD

change 更改

$consulta = "SELECT id,
                     id_musico,
                     asistenciaD,
                     FROM asistencia
                     WHERE id = ?";

to

$consulta = "SELECT id,
                     id_musico,
                     asistenciaD
                     FROM asistencia
                     WHERE id = ?";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 BasicNetwork.performRequest:意外的响应代码500 - BasicNetwork.performRequest: Unexpected response code 500 E / Volley:[126] BasicNetwork.performRequest:意外的响应代码500 - E/Volley: [126] BasicNetwork.performRequest: Unexpected response code 500 BasicNetwork.performRequest:意外的响应代码413? - BasicNetwork.performRequest: Unexpected response code 413? Android Volley:BasicNetwork.performRequest:意外的响应代码404 - Android Volley: BasicNetwork.performRequest: Unexpected response code 404 BasicNetwork.performRequest:意外的响应代码422 - BasicNetwork.performRequest: Unexpected response code 422 BasicNetwork.performRequest:意外的响应代码400(GET) - BasicNetwork.performRequest: Unexpected response code 400 (GET) Volley - BasicNetwork.performRequest:意外的响应代码400 POST - Volley - BasicNetwork.performRequest: Unexpected response code 400 POST Volley BasicNetwork.performRequest:意外的响应代码 301 - Volley BasicNetwork.performRequest: Unexpected response code 301 如何修复“Volley:[15771] BasicNetwork.performRequest:Android 中的意外响应代码 404? - How to fix "Volley: [15771] BasicNetwork.performRequest: Unexpected response code 404 in android? E / Volley:[145] BasicNetwork.performRequest:https://的意外响应代码404 - E/Volley: [145] BasicNetwork.performRequest: Unexpected response code 404 for https://
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM