Foros del Web » Programando para Internet » PHP »

php sobre paradox

Estas en el tema de php sobre paradox en el foro de PHP en Foros del Web. Hola Tengo una aplicación realizada en delphi que utiliza paradox como base de datos , la questión es que desde php ataco por obdc a ...
  #1 (permalink)  
Antiguo 01/02/2007, 06:33
 
Fecha de Ingreso: febrero-2007
Mensajes: 3
Antigüedad: 17 años, 2 meses
Puntos: 0
php sobre paradox

Hola

Tengo una aplicación realizada en delphi que utiliza paradox como base de datos , la questión es que desde php ataco por obdc a la base de datos de paradox y la conexión la realiza correctamente pero cuando intento realizar una query de consulta no hay manera de que me muestre ningun resultado.
Pero el mismo código sobre access me funciona.

Os paso el código a ver si me podeis ayudar

<?php
if ($conn_access = odbc_connect ( "ClientsInter", "", "")){
echo "Conectado correctamente"; // hasta aqui funciona correctamente
$ssql = 'select * from Empresa';
if($rs_access = odbc_exec ($conn_access, $ssql)){
echo "La sentencia se ejecutó correctamente";
while ($fila = odbc_fetch_object($rs_access)){
echo "<br>" . $fila->empresa;
}
}else{
echo "Error al ejecutar la sentencia SQL";
}
} else{
echo "Error en la conexión con la base de datos";
}


?>

Gracias
Atentamente Eduard
  #2 (permalink)  
Antiguo 14/06/2011, 09:39
 
Fecha de Ingreso: diciembre-2010
Mensajes: 3
Antigüedad: 13 años, 4 meses
Puntos: 1
Respuesta: php sobre paradox

intenta con este codigo tienes que cambiar varios paramentros

<?php
$dsn="pad";
$user=" ";
$pass=" ";
//connecting to the database using ODBC

$db = odbc_connect ( $dsn , $user , $pass )or die( "Error: Can't Connect to Database" );

// assigns a value how many rows we will get from each page
$limit = 15 ;

/* assign variable with sql query of counting how many rows are there in the database.
take note you should assign * with a table data name and table_name with table name*/
$query_count = "SELECT COUNT (*) as value FROM BLKBRD " ;

//executes the sql statement to the database
$result_count = odbc_exec ( $db , $query_count );

// get the result count from the database
$totalrows = odbc_fetch_object ( $result_count );

if(empty( $page )){ // Checks if the $page variable is empty (not set)
$page = 1 ; // If it is empty, we're on page 1
}

//this will be the lowest limit
$limitvalue = $page * $limit - ( $limit );
$limitnew = $limitvalue + $limit ;
// Ex: (2 * 25) - 25 = 25 <- data starts at 25
$query = "SELECT * FROM table_name where ID between $limitvalue and $limitnew ORDER BY ID ASC" ;

//executes the sql statement to the database
$result = odbc_exec ( $db , $query );

echo "<table><tr><td>Title1</td>
<td>Title2</td>" ;

// open loop to list down contents from the database
while (( $row = odbc_fetch_object ( $result ))) {

echo "<tr><td> $row -> content_title1 </td>
<td> $row -> content_title2 </td>" ;

//close the loop
}

//now we close the table
echo "</table>" ;

/*check if we are at page 1. if true, PREV will not be a link. if false, $page will be a link minus 1 page. */
if( $page != 1 ){
$pageprev = $page - 1 ;
echo( "&nbsp;<b><a href=" $PHP_SELF ? page = $pageprev ">PREV</a></b>&nbsp;" );
}else{
echo( "&nbsp;PREV&nbsp;" );
}

/* $numofpages will be the quotient of the total rows divided by the limit value
in this example lets assume that we have 47 rows in the database divided by 15 will result 3.13 */
$numofpages = $totalrows -> value / $limit ;

/* now let us generate those page numbers*/
for( $i = 1 ; $i <= $numofpages ; ++ $i ){
if( $i == $page ){
echo( "&nbsp;[ $i ]&nbsp;" );
}else{
echo( "&nbsp;<b><a href=" $PHP_SELF ? page = $i "> $i </a></b>&nbsp;" );
}
}

/* check if we have a remainder and print it at the end page list */
if(( $totalrows -> increm % $limit ) != 0 ){
if( $i == $page ){
echo( "&nbsp;[ $i ]&nbsp;" );
}else{
echo( "&nbsp;<b><a href=" $PHP_SELF ? page = $i "> $i </a></b>&nbsp;" );
}
}

/* finally we check the "next" link if we have a page to move on to, if yes we put it as a link adding another page.
in this example assuming that we have $totalrows->value=47
this will check if (47 - (15 * 1) = 32) > zero, results to true will give a link.*/
if(( $totalrows -> value - ( $limit * $page )) > 0 ){
$pagenext = $page + 1 ;

echo( "&nbsp;<b><a href=" $PHP_SELF ? page = $pagenext ">NEXT</a></b> " );
}else{
echo( "&nbsp;NEXT&nbsp;" );
}

// now let us free the resources
odbc_free_result ( $result );

?>
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Tema Cerrado




La zona horaria es GMT -6. Ahora son las 20:04.