MySQL Forums
Forum List  »  Spanish

Problema al conectar con sql en tablas
Posted by: Ric Rey
Date: February 19, 2021 02:13PM

Hola a todos, hice un pequeño php que me hace una consulta a la base de datos y como respuesta me llena la tablas con los datos que pido... el problema es que en el localhost funciona de maravilla pero al subir al hosting sale pantalla blanca con error 500, al parecer no he usado bien las partes, por favor ayúdenme soy novato :(

Este es el error_log del hosting.

[19-Feb-2021 19:58:39 UTC] PHP Fatal error: Uncaught mysqli_sql_exception: Table 'sistegra_banco.OS' doesn't exist in /home/sistegra/public_html/stecnico/consultaros/pages/tables/data.php:81
Stack trace:
#0 /home/sistegra/public_html/stecnico/consultaros/pages/tables/data.php(81): mysqli->query('SELECT OS.IDOS,...')
#1 {main}
thrown in /home/sistegra/public_html/stecnico/consultaros/pages/tables/data.php on line 81

Esto es el código que uso.

<?php

$nombre_Cliente = NULL;

$buscarPor = trim(filter_input(INPUT_POST,'Criterio', FILTER_SANITIZE_STRING));
$where = trim(strtolower(filter_input(INPUT_POST, 'itBuscar', FILTER_SANITIZE_STRING)));

$buscar = true;
if (empty($where))
{
$buscar = false;
}
if ($buscarPor === 'Email')
{
if(!filter_var($where, FILTER_VALIDATE_EMAIL))
{
$buscar = false;
}
}

$sq1 = "SELECT OS.IDOS, CLI.NOMECLIENTE, OS.DATAINICIAL, OS.DATAFINAL, OS.STATUS, OS.OBSERVACOES, OS.LAUDOTECNICO
FROM clientes CLI
INNER JOIN OS ON OS.Clientes_id = CLI.idClientes";

if ($buscar)
{
$datoBuscar = "'".$where."'";
if ($buscarPor === 'Documento')
{
$query = $sq1. " WHERE CLI.documento = $datoBuscar";
}
else
{
$query = $sq1. " WHERE CLI.email = $datoBuscar";
}

$cn = new mysqli('localhost', 'root', '', 'stecnico');
$rs = $cn->query($query);
$rs = $cn->query($query);
$nombre_Cliente = $rs->fetch_assoc()['NOMECLIENTE'];
$vecresultado = array();
while ($fila = $rs->fetch_row())
{
//$nombre_Cliente = ($fila[1]);
array_push($vecresultado, $fila);
}

mysqli_free_result($rs);
mysqli_close($cn);
}
else
{
header("Location: /stecnico/consultaros/index.php?Error=s");
}
?>

Options: ReplyQuote


Subject
Views
Written By
Posted
Problema al conectar con sql en tablas
874
February 19, 2021 02:13PM
254
February 19, 2021 03:17PM
204
February 19, 2021 03:25PM
214
February 19, 2021 05:32PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.