potete dare un'occhiata a questo codice qui sotto, basta copiarlo in una pagina php ed è pronto per essere provato!!
non riesco ad iserire i dati nel database SQLite!!
chiaro che sto facendo prove con PHP5
Codice PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Documento senza titolo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
if (!empty($_GET)) extract($_GET);
else if (!empty($HTTP_GET_VARS)) extract($HTTP_GET_VARS);
if (!empty($_POST)) extract($_POST);
else if (!empty($HTTP_POST_VARS)) extract($HTTP_POST_VARS);
ini_set('track_errors', '1');
switch ($_GET['action']) {
default:
?>
<form name="form1" method="post" action="<?php echo"$_SERVER[PHP_SELF]?action=add"; ?>">
<input type="textfield" name="name">
<textarea name="text"></textarea>
<input type="submit" name="Submit" value="Invia">
</form>
<?php
break;
case "add":
$dbFile = realpath('./').'/testDB' ;
$dbLink=@sqlite_open($dbFile) ;
if(!is_resource($dbLink)){
$sqliteError= "Fehler, Si è verificato un errore al momento dell'apertura/creazione del database
\n";
$sqliteError.= '[b]'.$php_errormsg.'[/b]' ;
$php_errormsg='' ;
exit($sqliteError) ;
}
$queryTable = 'CREATE TEMPORARY TABLE clienti(
-- id_cliente è un campo autoincrement
id_cliente INTEGER PRIMARY KEY,
-- il nome del cliente
nome_cliente VARCHAR(20),
/*
Commento multi-line per il
cognome del cliente
*/
cognome_cliente VARCHAR(35)
)';
if(!@sqlite_query ($dbLink, $queryTable)){
$sqliteError= "[b], Fehler Table, Impossibile eseguire la query[/b]
\n";
$sqliteError.= "$queryTable
\n";
$sqliteError.= '[b]'.$php_errormsg.'[/b]' ;
$php_errormsg='' ;
exit($sqliteError) ;
}
$queryInsert = "INSERT INTO clienti (id_cliente, nome_cliente, cognome_cliente) " ;
$queryInsert .= "VALUES (NULL, $name, $text)" ;
if(!@sqlite_query ($dbLink, $queryInsert)){
$sqliteError= "[b] fehler Insert, Impossibile eseguire la query[/b]
\n";
$sqliteError.= "$query
\n";
$sqliteError.= '[b]'.$php_errormsg.'[/b]' ;
$php_errormsg='' ;
exit($sqliteError) ;
}
var_export($result) ;
sqlite_close($dbLink) ;
break;
}
?>
</body>
</html>
grazie
kirk