Hello,
i have a Blog Script for my private Website. Normal i write new Articles
direct with phpmyadmin, but this is not comfortable. I has no errors in Log
for the script and the mysql query log write the correct insert SQL code, but
nothing would be write in the database. I really understand not where is the
mistake. Can someone help me?
Thank You! Wish nice day at all!
Regards
Silvio
My PHP Code:
<start>
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require ("inc/db.html");
var_dump($_POST);
// Check the Fields
if (isset ($_POST['submit']) &&
isset ($_POST['autor']) &&
isset ($_POST['title']) &&
isset ($_POST['teaser']) &&
isset ($_POST['content']) &&
isset ($_POST['category']) &&
isset ($_POST['bild']) &&
$_POST['autor'] != '' &&
$_POST['title'] != '' &&
$_POST['teaser'] != '' &&
$_POST['content'] != '' &&
$_POST['category'] != '' &&
$_POST['bild'] != '') {
try {
$sql = "INSERT INTO `test` (autor, title, teaser, content, category, bild)
VALUES
(:autor, :title, :teaser, :teaser, :content, :category, :bild)";
$write = $db->prepare($sql);
$write->bindValue(':autor', $_POST['autor']);
$write->bindValue(':title', $_POST['title']);
$write->bindValue(':teaser', $_POST['teaser']);
$write->bindValue(':content', $_POST['content']);
$write->bindValue(':category', $_POST['category']);
$write->bindValue(':bild', $_POST['bild']);
$write->execute();
echo "<h1>Artikel ist eingetragen!</h1>";
} catch (PDOException $ex) {
echo $ex->getMessage();
}
}
?>
</end>
The HTML Tags:
<start>
<div class="entry">
<form method="post" action="" />
<fieldset>
<label>Autor</label>
<input type="text" class="text" name="autor" />
<label>Title</label>
<input type="text" class="text" name="title" />
<label>Teaser</label>
<textarea cols="80" rows="10" class="textarea" name="teaser"></textarea>
<label>Content</label>
<textarea cols="80" rows="10" class="textarea" name="content"></textarea>
<label>Kategorie</label>
<input type="text" class="text" name="category" />
<label>Bild</label>
<input type="text" class="text" name="bild" />
<input type="submit" class="submit" name="submit" value="Posten" />
</fieldset>
</form>
</div>
</end>
The Mysql Query Log:
<start>
110516 2:44:29 187 Connect root@localhost on bloggen
187 Query INSERT INTO `test` (autor, title, teaser,
content, category, bild) VALUES ('Silvio Siefke', 'Test', 'We try we can
write in database with the script.', 'We try we can write in database with
the script.', 'When not then i not know what is the problem with the
script.', 'Freizeit', 'content.png') 187 Quit
<end>
The var_dump give me:
<start>
array(7) { ["autor"]=> string(13) "Silvio Siefke" ["title"]=> string(4)
"Test" ["teaser"]=> string(48) "We try we can write in database with the
script." ["content"]=> string(61) "When not then i not know what is the
problem with the script." ["category"]=> string(8) "Freizeit" ["bild"]=>
string(11) "content.png" ["submit"]=> string(6) "Posten" }
<end>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php