Php odbc postresql

0

I need your help for days fighting to solve this error :

  

syntax error, unexpected 'else' (T_ELSE)

The code in php is as follows:

<?php
include('conexion.php');

$desde = $_POST['desde'];
$hasta = $_POST['hasta'];

//COMPROBAMOS QUE LAS FECHAS EXISTAN
if(isset($desde)==false){
    $desde = $hasta;
}

if(isset($hasta)==false){
    $hasta = $desde;
}

//EJECUTAMOS LA CONSULTA DE BUSQUEDA

$registro = "SELECT * FROM tarificado.rep_con WHERE fecha_dcms BETWEEN '$desde' AND '$hasta'";


echo '<table class="table table-striped table-condensed table-hover">
            <tr>
                <th width="200">central</th>
                <th width="150">centrales_nombre</th>
                <th width="150">fecha_dcms</th>
                <th width="150">archivo_dcms</th>
                <th width="150">correlativo_dcms</th>
                <th width="150">bytes_dcms</th>
                <th width="150">archivo_ivr</th>
                <th width="150">correlativo_ivr</th>
                <th width="150">fecha_ivr</th>
                <th width="150">bytes_ivr</th>
                <th width="150">ivr_num_eventos</th>
                <th width="150">dif_bytes</th>      
            </tr>';
if(($registro)>0);
{
    while($registro2 =($registro)){
        echo '<tr>
                <td>'.$registro2['Central'].'</td>
                <td>'.$registro2['centrales_nombre'].'</td>
                <td>'.$registro2['fecha_dcms'].'</td>
                <td>'.$registro2['archivo_dcms'].'</td>
                <td>'.$registro2['correlativo_dcms'].'</td>
                <td>'.$registro2['bytes_dcms'].'</td>
                <td>'.$registro2['archivo_ivr'].'</td>
                <td>'.$registro2['correlativo_ivr'].'</td>
                <td>'.$registro2['fecha_ivr'].'</td>
                <td>'.$registro2['bytes_ivr'].'</td>
                <td>'.$registro2['ivr_num_eventos'].'</td>
                <td>'.$registro2['dif_bytes'].'</td>
                </tr>';
    }
**}else{**  <---- esta es la linea 55.
    echo '<tr>
                <td colspan="6">No se encontraron resultados</td>
            </tr>';
}

echo '</table>';
?>

I appreciate your support.

    
asked by Grindor 18.04.2018 в 21:49
source

2 answers

0

you could use something easier pg_connect ()

Connection example

<?php
    function conectar_PostgreSQL( $usuario, $pass, $host, $bd )
    {
         $conexion = pg_connect( "user=".$usuario." ".
                                "password=".$pass." ".
                                "host=".$host." ".
                                "dbname=".$bd
                               ) or die( "Error al conectar: ".pg_last_error() );
        return $conexion;
    }
?>

search example by id

<?php
    function buscarPersona( $conexion, $id )
    {
        $sql = "SELECT * FROM tbl_personas WHERE id=".$id."";
        $devolver = null;
        // Ejecutar la consulta:
         $rs = pg_query( $conexion, $sql );
        if( $rs )
        {
            // Si se encontró el registro, se obtiene un objeto en PHP con los datos de los campos:
             if( pg_num_rows($rs) > 0 )
                 $devolver = pg_fetch_object( $rs, 0 );
        }
        return $devolver;
    }
?>

It is certainly much easier in this way, but it will help you!

    
answered by 18.04.2018 в 22:15
0

You have

if(($registro)>0);
{

so the closing bracket on the wrong line and the else are not instructions the interpreter waits for.

    
answered by 18.04.2018 в 22:18