Error PHP PHP AngularJS

0

I just uploaded my project to a server, but it turns out that I get a response from the server (Status: 500), this is a short query on my home page regarding the cities:

  

I have read about it and I have found that it may be because of the    .htacces but I have not implemented it yet, so I discard that option, and the log does not return any error either

<?php
  header("Context-type: application/json;");

  require '../conexion.php';
  $mysqli->set_charset('utf8');
  $resultadoConsultaCiudad = $mysqli->query("SELECT cdes.id_ciudad,
                                                      cdes.ciudad,
                                                    dpto.id_departamento,
                                                    dpto.departamento
                                                FROM ciudades cdes
                                                INNER JOIN departamento dpto
                                                ON dpto.id_departamento = cdes.id_departamento");

  $dataSalidaCiudad = array();

  while ($row = $resultadoConsultaCiudad->fetch_assoc())
  {
    $dataSalidaCiudad[] = $row;
  }

  echo json_encode($dataSalidaCiudad);
?>

This is the client part (AngularJS):

//FUNCION QUE SE ENCARGA DE OBTENER LOS DATOS DE LA TABLA CIUDAD
  $scope.importarDatosCiudad = function()
  {
    $http({
        method: 'GET',
        url: 'mainApp/Read/consultarCiudades.php'
      })
      .then(function successCallback(datosCiudad)
      {
        $scope.tableCiudades = datosCiudad.data;

      },function errorCallback(datosCiudad)
      {
        console.log("Error, al tratar de traer los datoss", datosCiudad)
      });
  }
  $scope.importarDatosCiudad();

result:

  

{data: "", status: 500, config: {...}, statusText: "Internal Server   Error ", headers: ƒ} config: {method:" GET ", transformRequest:   Array (1), transformResponse: Array (1), jsonpCallbackParam: "callback",   paramSerializer: ƒ, ...} data: "" headers: ƒ (d) status: 500   statusText: "Internal Server Error"    proto : Object

    
asked by jecorrales 08.10.2017 в 02:00
source

1 answer

1

I can not give you a direct answer of what is failing you in the code, I invite you to activate the errors of php to find out what and where is failing. You can do this easily by adding this code to the beginning of your .php .

error_reporting(E_ALL);
ini_set('display_errors', '1');

Remember that the development environment is convenient to have errors and warnings activated, however in the production environment it is best to have them hidden and be able to review them from the log.

You can enable errors by default (so you do not have to write the code above everywhere) in your php.ini by changing display_errors from Off to On.

display_errors = On
    
answered by 09.10.2017 / 11:12
source