Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/05/2011, 10:46
Avatar de zibor
zibor
 
Fecha de Ingreso: diciembre-2006
Mensajes: 80
Antigüedad: 17 años, 4 meses
Puntos: 1
Problemas con SQLite

Buenas.
Estoy utilizando SQLite. Me instalé el complemento SQLite manager para firefox.
Con dicho complemento creo la BD y le inserto una tupla con datos.

Estoy haciendo unas estadisticas sobre las visitas que se hacen hacia un documento.
Inserto idDocumento,nvisitas,titulo si es nuevo en SQLite o hago un updatesi ya existe.


error:
Código:
Warning: SQLite3::query() [sqlite3.query]: Unable to prepare statement: 1, no such table: masleidos in C:\xampp\htdocs\Docuteca\modulos\visor\visor.php on line 58

Warning: SQLite3::query() [sqlite3.query]: Unable to prepare statement: 1, no such table: masleidos in C:\xampp\htdocs\Docuteca\modulos\visor\visor.php on line 66

SQLite: error 1 - no such table: masleidos
La conexion mediante php5 y sql3 es:
Código PHP:
function abrirSQLite(){
    if((
$link = new SQLite3("estadisticas2.sqlite"))){
        return 
$link;
    }else{
        
erroresSQLite($link);
        return 
0;
    }
}
function 
cerrarSQLite($link){
    
$link->close();
}
function 
erroresSQLite($link){
    
$num $link->lastErrorCode();
    
$msg $link->lastErrorMsg();

    switch(
$num){
        case 
19:
            echo 
"<div class='errEnlaces'>SQLite: error ".$num." - Nombre duplicado.</div>";
        break;
        default:
            echo 
"<div class='errEnlaces'>SQLite: error ".$num." - ".$msg."</div>";
    }

el codigo para hacer el insert:
Código PHP:
function estadisticas($id,$titulo){
      $link = abrirSQLite();
    
      if(($result = $link->query("select nvisitas from masleidos where idDocu='".$id."' "))){
          while(($row = $result->fetchArray())){
                if(!($result = $link->query("update masleidos set nvisitas='".($row["nvisitas"]+1)."' where idDocu='".$id."' "))){
                  ?><div class="errEnlaces">ERROR. No se actualizó la estadistica.update</div><?php
                  erroresBD
($link);
                } 
          }
      }else{
            if(!(
$result $link->query("insert into masleidos (idDocu,nvisitas,titulo) values('".$id."',1,'".$titulo."')"))){
              
?><div class="errEnlaces">ERROR. No se actualizó la estadistica.insert</div><?php
                  erroresSQLite
($link);
            }
      }
      
cerrarSQLite($link);
}
Si hay algun conocedor sobre el tema espero que me puedan ayudar sobre el tema.
Gracias de antemano.

Saludos.
__________________
Picando código...!!!