Problem mit PHP & SQL beim schreiben von time()
Frank
- php
hallo!
das ist mein query:
$sql = "INSERT INTO news
(Autor, Titel, Inhalt, Datum)
VALUES
('".addslashes(htmlspecialchars($_POST['author']))."',
'".addslashes(htmlspecialchars($_POST['titel']))."',
'".addslashes(htmlspecialchars($_POST['text']))."',
'time()')";
nur das problem ist, das ich den timestamp in die Datenbank eintragen lassen möchte! nur mit time macht der das net!
UNd wie muss ich in der DB die Spalte vom Datum definieren, also welchen Typ ???
Kann mir da einer helfen ?
Hoffe ihr versteth mein Problem!
Wo ist mein Fehler!
in der db steht bei Datum dann immer nur 0
Die Spalte nimmst du am besten als INT UNSIGNED.
$sql = "INSERT INTO news
(Autor, Titel, Inhalt, Datum)
VALUES
('".addslashes(htmlspecialchars($_POST['author']))."',
'".addslashes(htmlspecialchars($_POST['titel']))."',
'".addslashes(htmlspecialchars($_POST['text']))."',
'".time()."')";
oder
$sql = "INSERT INTO news
(Autor, Titel, Inhalt, Datum)
VALUES
('".addslashes(htmlspecialchars($_POST['author']))."',
'".addslashes(htmlspecialchars($_POST['titel']))."',
'".addslashes(htmlspecialchars($_POST['text']))."',
UNIX_TIMESTAMP (NOW ()))";
DANKE SEHR!
HAT GEKLAPPT! =)
Die Spalte nimmst du am besten als INT UNSIGNED.
$sql = "INSERT INTO news
(Autor, Titel, Inhalt, Datum)
VALUES
('".addslashes(htmlspecialchars($_POST['author']))."',
'".addslashes(htmlspecialchars($_POST['titel']))."',
'".addslashes(htmlspecialchars($_POST['text']))."',
'".time()."')";oder
$sql = "INSERT INTO news
(Autor, Titel, Inhalt, Datum)
VALUES
('".addslashes(htmlspecialchars($_POST['author']))."',
'".addslashes(htmlspecialchars($_POST['titel']))."',
'".addslashes(htmlspecialchars($_POST['text']))."',
UNIX_TIMESTAMP (NOW ()))";