Jump to content

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

  • 1 month later...

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.