Hi!
I am trying to insert with PDO-Sqlite rows through a form. I can do
whatever I want, I don't find the sollution where I made the error.
Perhaps somebody of you could help me?!
However, the database is created with sqlite, and the entries should be
done with PDO_SQLITE. However, no entries are done anyways and I am one
step going nuts, specially because I don't receive no warning or
errormessage on the screen.
For any help, I would thank you very much.
Tamer
Code:
<?php
require_once('H TML/Form.php');
require_once('I 18N/UnicodeString.p hp');
require_once('H TML/Table.php');
class Formular
{
private $ServerVar = array("Auswahl" ,"Betreff","Ein gabe");
function __construct()
{
$this->ServerVar["Auswahl"] = $_GET['Auswahl'];
$this->ServerVar["Betreff"] = $_GET['Feld'];
$this->ServerVar["Eingabe"] = $_GET['Eingabe'];
$this->MeinFormular() ;
//$this->sqdb();
if(($this->ServerVar["Betreff"] === null) or
($this->ServerVar["Eingabe"] === null))
{
$this->MeineDB();
$this->TextFeld();
}
elseif (($this->ServerVar["Betreff"] === "") or
($this->ServerVar["Eingabe"] === ""))
{
$this->MeineDB();
$this->TextFeld();
}
else
{
$Auswahl = $this->ServerVar["Auswahl"];
$Betreff = $this->ServerVar["Betreff"];
$Eingabe = $this->ServerVar["Eingabe"];
$this->MeineDB2($Ausw ahl,$Betreff,$E ingabe);
$this->TextFeld();
}
}
private function MeineDB()
{
try
{
$dbh = new
PDO('sqlite2:/home/tamer/public_html/citybaker/WebContent/mysqlitedb');
$sql = 'select * from Daten';
foreach ($dbh->query($sql) as $row)
{
//print_r($row);
}
$this->ServerVar = $row;
$dbh = null;
}
catch (PDOException $e)
{
die("Can't connect!");
}
}
private function Datei()
{
$Eigen =
fileowner('/home/tamer/public_html/citybaker/WebContent/formular.sq2');
print(fileperms ('/home/tamer/public_html/citybaker/WebContent/formular.sq2')) ;
//print($Eigen);
}
private function MeineDB2($selec tion,$subj,$inp ut)
{
switch ($selection)
{
case 0:
$selection = 'Deutsch';
break;
case 1:
$selection = 'Englisch';
break;
case 2:
$selection = "Arabisch";
break;
}
$DBWerte = 'insert into Daten
values('.'"'.$s election.'","'. $subj.',"'.$inp ut.')';
//print($DBWerte) ;
try
{
$dbh = new
PDO('sqlite2:/home/tamer/public_html/citybaker/WebContent/mysqlitedb');
//$dbh->beginTransacti on();
$dbh->exec($DBWerte) ;
//$dbh->commit();
$dbh = null;
$this->ServerVar = $row;
}
catch (PDOException $e)
{
//$dbh->rollBack();
echo "Failed: ".$e->getMessage() ;
}
}
private function MeinFormular()
{
$Sprachen = array('deutsch' ,'englisch','ar abisch');
$Formular = new
HTML_Form("Form ular.php",'get' ,'Meinformular' ,'',"text/plain","accept-charset=utf-8");
$Formular->addSelect("Aus wahl","Auswahl" ,$Sprachen);
$Formular->addText("Feld" ,"Betreff",null ,50,50);
$Formular->addTextarea("E ingabe","Eingab efeld",null,50, 10,10);
$Formular->addSubmit('sub mit','absenden! ');
$Formular->display();
}
private function TextFeld()
{
$TabelleAttribu te = array("border"= >"1");
$Tabelle = new HTML_Table($Tab elleAttribute,0 ,false);
$Tabelle->addCol($this->MeinArrayText) ;
print($Tabelle->toHtml());
}
private function sqdb()
{
if ($db = sqlite_open('my sqlitedb', 0666, $sqliteerror))
{
sqlite_query($d b, 'CREATE TABLE Daten (sprache varchar(100),be treff
varchar(100),fe ld varchar(1000))' );
//sqlite_query($d b, "INSERT INTO foo VALUES ('fnord')");
//$result = sqlite_query($d b, 'select bar from foo');
//var_dump(sqlite _fetch_array($r esult));
} else {
die($sqliteerro r);
}
}
}
?>
I am trying to insert with PDO-Sqlite rows through a form. I can do
whatever I want, I don't find the sollution where I made the error.
Perhaps somebody of you could help me?!
However, the database is created with sqlite, and the entries should be
done with PDO_SQLITE. However, no entries are done anyways and I am one
step going nuts, specially because I don't receive no warning or
errormessage on the screen.
For any help, I would thank you very much.
Tamer
Code:
<?php
require_once('H TML/Form.php');
require_once('I 18N/UnicodeString.p hp');
require_once('H TML/Table.php');
class Formular
{
private $ServerVar = array("Auswahl" ,"Betreff","Ein gabe");
function __construct()
{
$this->ServerVar["Auswahl"] = $_GET['Auswahl'];
$this->ServerVar["Betreff"] = $_GET['Feld'];
$this->ServerVar["Eingabe"] = $_GET['Eingabe'];
$this->MeinFormular() ;
//$this->sqdb();
if(($this->ServerVar["Betreff"] === null) or
($this->ServerVar["Eingabe"] === null))
{
$this->MeineDB();
$this->TextFeld();
}
elseif (($this->ServerVar["Betreff"] === "") or
($this->ServerVar["Eingabe"] === ""))
{
$this->MeineDB();
$this->TextFeld();
}
else
{
$Auswahl = $this->ServerVar["Auswahl"];
$Betreff = $this->ServerVar["Betreff"];
$Eingabe = $this->ServerVar["Eingabe"];
$this->MeineDB2($Ausw ahl,$Betreff,$E ingabe);
$this->TextFeld();
}
}
private function MeineDB()
{
try
{
$dbh = new
PDO('sqlite2:/home/tamer/public_html/citybaker/WebContent/mysqlitedb');
$sql = 'select * from Daten';
foreach ($dbh->query($sql) as $row)
{
//print_r($row);
}
$this->ServerVar = $row;
$dbh = null;
}
catch (PDOException $e)
{
die("Can't connect!");
}
}
private function Datei()
{
$Eigen =
fileowner('/home/tamer/public_html/citybaker/WebContent/formular.sq2');
print(fileperms ('/home/tamer/public_html/citybaker/WebContent/formular.sq2')) ;
//print($Eigen);
}
private function MeineDB2($selec tion,$subj,$inp ut)
{
switch ($selection)
{
case 0:
$selection = 'Deutsch';
break;
case 1:
$selection = 'Englisch';
break;
case 2:
$selection = "Arabisch";
break;
}
$DBWerte = 'insert into Daten
values('.'"'.$s election.'","'. $subj.',"'.$inp ut.')';
//print($DBWerte) ;
try
{
$dbh = new
PDO('sqlite2:/home/tamer/public_html/citybaker/WebContent/mysqlitedb');
//$dbh->beginTransacti on();
$dbh->exec($DBWerte) ;
//$dbh->commit();
$dbh = null;
$this->ServerVar = $row;
}
catch (PDOException $e)
{
//$dbh->rollBack();
echo "Failed: ".$e->getMessage() ;
}
}
private function MeinFormular()
{
$Sprachen = array('deutsch' ,'englisch','ar abisch');
$Formular = new
HTML_Form("Form ular.php",'get' ,'Meinformular' ,'',"text/plain","accept-charset=utf-8");
$Formular->addSelect("Aus wahl","Auswahl" ,$Sprachen);
$Formular->addText("Feld" ,"Betreff",null ,50,50);
$Formular->addTextarea("E ingabe","Eingab efeld",null,50, 10,10);
$Formular->addSubmit('sub mit','absenden! ');
$Formular->display();
}
private function TextFeld()
{
$TabelleAttribu te = array("border"= >"1");
$Tabelle = new HTML_Table($Tab elleAttribute,0 ,false);
$Tabelle->addCol($this->MeinArrayText) ;
print($Tabelle->toHtml());
}
private function sqdb()
{
if ($db = sqlite_open('my sqlitedb', 0666, $sqliteerror))
{
sqlite_query($d b, 'CREATE TABLE Daten (sprache varchar(100),be treff
varchar(100),fe ld varchar(1000))' );
//sqlite_query($d b, "INSERT INTO foo VALUES ('fnord')");
//$result = sqlite_query($d b, 'select bar from foo');
//var_dump(sqlite _fetch_array($r esult));
} else {
die($sqliteerro r);
}
}
}
?>