4

Tengo el siguiente código. Al momento que ejecuto en el navegador me indica el único error:

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

la linea 64 es la siguiente:

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

codigo php

<?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>';

?>

Donde las variables han sido definidas previamente asi

$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;";
2
  • En donde defines las variables $sql y $cid?
    – alanfcm
    el 10 may. 2018 a las 21:40
  • La defino por medio de una query es la siguiente:$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;";
    – Grindor
    el 10 may. 2018 a las 21:42

1 respuesta 1

2

El problema es que tienes los parametros al revez. Primero va la conexion y despues el query asi:

$result = odbc_exec($cid, $sql);
3
  • Muchas gracias Alanfcm ahora solucione el error, te lo agradezco ya funciona, perdon pero soy nuevo aun en la programacion. saludos.
    – Grindor
    el 10 may. 2018 a las 21:50
  • De nada, por cierto, yo tambien soy Chapin
    – alanfcm
    el 10 may. 2018 a las 22:07
  • Ohh genial me llegas primo!!! buena honda.
    – Grindor
    el 10 may. 2018 a las 23:16

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.