(PDO) database entries are not possible, even without errorfeedback!
am 28.03.2006 15:42:10 von Tamer HigaziHi!
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:
require_once('HTML/Form.php');
require_once('I18N/UnicodeString.php');
require_once('HTML/Table.php');
class Formular
{
private $ServerVar = array("Auswahl","Betreff","Eingabe");
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($Auswahl,$Betreff,$Eingabe);
$this->TextFeld();
}
}
private function MeineDB()
{
try
{
$dbh = new
PDO('sqlite2:/home/tamer/public_html/citybaker/WebContent/my sqlitedb');
$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 MeineDB2($selection,$subj,$input)
{
switch ($selection)
{
case 0:
$selection = 'Deutsch';
break;
case 1:
$selection = 'Englisch';
break;
case 2:
$selection = "Arabisch";
break;
}
$DBWerte = 'insert into Daten
values('.'"'.$selection.'","'.$subj.',"'.$input.')';
//print($DBWerte);
try
{
$dbh = new
PDO('sqlite2:/home/tamer/public_html/citybaker/WebContent/my sqlitedb');
//$dbh->beginTransaction();
$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','arabisch');
$Formular = new
HTML_Form("Formular.php",'get','Meinformular','',"text/plain ","accept-charset=utf-8");
$Formular->addSelect("Auswahl","Auswahl",$Sprachen);
$Formular->addText("Feld","Betreff",null,50,50);
$Formular->addTextarea("Eingabe","Eingabefeld",null,50,10,10 );
$Formular->addSubmit('submit','absenden!');
$Formular->display();
}
private function TextFeld()
{
$TabelleAttribute = array("border"=>"1");
$Tabelle = new HTML_Table($TabelleAttribute,0,false);
$Tabelle->addCol($this->MeinArrayText);
print($Tabelle->toHtml());
}
private function sqdb()
{
if ($db = sqlite_open('mysqlitedb', 0666, $sqliteerror))
{
sqlite_query($db, 'CREATE TABLE Daten (sprache varchar(100),betreff
varchar(100),feld varchar(1000))');
//sqlite_query($db, "INSERT INTO foo VALUES ('fnord')");
//$result = sqlite_query($db, 'select bar from foo');
//var_dump(sqlite_fetch_array($result));
} else {
die($sqliteerror);
}
}
}
?>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php