Error in php and sql by odbc connection

4

I have the following code. The moment I run in the browser it tells me the only error:

  

odbc_exec () expects parameter 1 to be resource, string given in C: \ AppServ \ www \ central \ index.php on line 64

line 64 is as follows:

$result = odbc_exec($sql,$cid);

php code

<?php include("templates/header.php"); ?>
<h1>Centrales vs Mediacion</h1>
<h3>Listado de Centrales</h3>
<div id="filtros">
Selecciona la central <form action="index.php" method="post"><select name="filtro"><option value="todos"></option><option value="Nimajuyu">Nimajuyu</option><option value="El Carmen 2">El Carmen 2</option><option value="Monte Verde 5">Monte Verde 5</option><option value="Lourdes EIN">Lourdes EIN</option><option value="Guarda Transito">Guarda Transito</option><option value="Guarda Viejo 5">Guarda Viejo 5</option><option value="Centro Transito EIN">Centro Transito EIN</option><option value="Tivoli">Tivoli</option><option value="Villa de Guadalupe 3">Villa de Guadalupe 3</option><option value="Aristos">Aristos</option><option value="Chimaltenango">Chimaltenango</option><option value="Retalhuleu">Retalhuleu</option><option value="Zacapa">Zacapa</option></select> <button type="submit">Filtrar</button></form>
</div>
<div id="productos">
    <?php
        $result = odbc_exec($sql,$cid);
        echo '<table class="table table-striped table-condensed table-hover">
            <tr>
                <th width="150">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 = odbc_fetch_array($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{
    echo '<tr>
                <td colspan="6">No se encontraron resultados</td>
            </tr>';
}
echo '</table>';

?>

Where the variables have been previously defined so

$sql = "select * from tarificado.rep_con where extract(week from fecha_dcms) in(19) AND central in (208) order by central,correlativo_dcms, archivo_dcms;";
    
asked by Grindor 10.05.2018 в 23:39
source

1 answer

2

The problem is that you have the parameters in reverse. First the connection goes and then the query like this:

$result = odbc_exec($cid, $sql);
    
answered by 10.05.2018 / 23:47
source