You are here: (PDO) database entries are not possible, even without errorfeedback! « PHP Programming Language « IT news, forums, messages
(PDO) database entries are not possible, even without errorfeedback!

Posted by Tamer Higazi on 11/18/25 11:43

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('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/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($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/mysqlitedb');
//$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);
}
}
}


?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация