Salve a tutti,
vorrei inserire in una tabella del mio database del testo e la data dell'inserimento.
Nella tabella (testi) ho 2 attributi: 'testo' e 'data'.
Ho scritto questo codice:
if (isset($_POST['testo'])) {
$testo = $_POST['testo'];
$sql = "INSERT INTO 'testi' SET
testo='$testo',
data=CURDATE()";
if (@mysql_query($sql)) {
echo '
Testo aggiunto correttamente.</p>';
} else { echo '
Errore nell'aggiunta del testo: ' . mysql_error() . '</p>';
}
}
Se scrivo direttamente il codice su MySQL funziona, ma con php no. Mi restituisce:
Errore nell'aggiunta del testo: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''testi' SET testo='testo nuovo', data=CURDATE()' at line 1
c'è qualcuno che può aiutarmi?![]()
p.s.: sono alle prime armi.
Grazie.