Jump to content

Archived

This topic is now archived and is closed to further replies.

itetcboo

Blank results when adding any clause to sql sentence in php + odbc + msaccess

Recommended Posts

Hi all!

I have a mdb db, which I can access through odbc via php, but I can only make sql sentences like select * from mytable.

If I add a WHERE clause or something else, I get a blank page.

 

I have created a simple index.php with this code:

 

<?php

if ($conn_access = odbc_connect ( "gestoria", "", "",SQL_CUR_USE_ODBC))
        {
        echo "Conectado correctamente" . "<BR>";
        $ssql = "select * from expedientes where numero_expediente=1";
        echo "<BR>" . $ssql . "<BR>";
        if($rs_access = odbc_exec ($conn_access, $ssql)){
                echo odbc_num_rows($rs_access);
                echo "sql sentence succesfull";
                        while ($fila = odbc_fetch_object($rs_access)){
                        $fila = odbc_fetch_object($rs_access);
                        echo "<br>" . $fila->numero_expediente;
                }
        }else{ 
                echo "error trying to execute SQL";
                }
} else{
    echo "Error conexion with db";
}
?>

 

any help please?

 

10x in advance

Share this post


Link to post
Share on other sites

Did you try to manually echo out the query and execute it trough other means?

 

Adding a

if (odbc_error())
{
    echo odbc_errormsg($conn);
}

might proof useful as well.

Share this post


Link to post
Share on other sites

Thanks for your answer,

 

I have put the code like this (entire code):

 

<?php

if ($conn_access = odbc_connect ( "gestoria", "", ""))
        {
        echo "Conectado correctamente" . "<BR>";
        $ssql = "select numero_expediente from expedientes where numero_expediente=1";
        echo "<BR>" . $ssql . "<BR>";
        if (odbc_error())
{
    echo odbc_errormsg($conn_access);
}
        if($rs_access = odbc_exec ($conn_access, $ssql)){
                echo "La sentencia se ejecuto correctamente";
                        $fila = odbc_fetch_row($rs_access,1);
                        echo $fila;
                        echo "<br>" . $fila->numero_expediente;

        }else{ //la sentencia no era correcta
                echo "Error al ejecutar la sentencia SQL";
                }
} else{
        if (odbc_error())
{
    echo odbc_errormsg($conn_access);
}

    echo "Error en la conexion con la base de datos";
}
?>

 

but nothing appears in the screen, just blank.. any other suggestion?

 

Thanks.

Share this post


Link to post
Share on other sites

So what happened when you manually executed the query, nothing as well?

Share this post


Link to post
Share on other sites

it seems a problem with suhosin patch, I'm trying to disable it....

I'll continue reporting you

 

Thanks so much.

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.