Wegen das Fehler mit,
$db->close();
return $ok;
hier sagt eine losung..mit $this->db = null;
Wie jetzt meine writeCommentToDatabase() habe,
function writeCommentToDatabase()
{
// Establish connection with MYSQL Server
try
{
$db = new PDO("mysql:host=localhost;dbname=meine", "root", "pass");
}
catch (PDOException $pe)
{
echo "<br>Cannot connect to database: " . $pe->getMessage();
return false;
}
//Prepare Query of SQL
$statement = $db->prepare("INSERT INTO mela(name, email, message, datetime, ips) VALUES (:name, :email, :message, :date, :ips)");
if (!$statement)
{
echo "<br><br>prepare failed: SQLSTATE=" . $db->errorCode() . ", Error Info=" . print_r($dbh->errorInfo(), true) . "</p>";
$ok = FALSE;
}
else
{
$ok = $statement->bindValue(':name', $this->Name, PDO::PARAM_STR)
&& $statement->bindValue(':email', $this->Email, PDO::PARAM_STR)
&& $statement->bindValue(':message', $this->Message, PDO::PARAM_STR)
&& $statement->bindValue(':date', date("Y-m-d H:i:s"), PDO::PARAM_STR)
&& $statement->bindValue(':ips', $this->ips, PDO::PARAM_STR);
if (!$ok)
{
echo "<br><br>bindValue failed: SQLSTATE=" . $db->errorCode() . ", Error Info=" . print_r($dbh->errorInfo(), true) . "</p>";
}
}
if ($ok)
{
$ok = $statement->execute();
if (!$ok)
{
echo "<br><br>execute failed: SQLSTATE=" . $db->errorCode() . ", Error Info=" . print_r($dbh->errorInfo(), true) . "</p>";
}
}
echo "<br/><br/><span>Data Inserted successfully...!!</span>";
$this->db = null;
return $ok;
}
Die Daten wird noch nicht auf meine Webseite geschrieben...