Oppure

Loading
29/07/11 12:22
MillenniumBug
Ciao a tutti ho u problema nell'inserimento del messaggio di un utente ad un altro nel database.
Questo è il codice:
<html>
<head>
<title>Scrivi Messaggio</title>
</head>
<body>
<?php
session_start();
include("conn.php");
class pctmess {
	public $user_m;
	public $user_d;
	public $ogg;
	public $mess;
		public function __construct($m,$d,$o,$me) {
			$this->user_m = $m;
			$this->user_d = $d;
			$this->ogg = $o;
			$this->mess = $me;
		}
		public function invia() {
			if ($this->ogg == "" || $this->mess == "") {
				echo "Inserisci oggetto o messaggio";
				} else {
			mysql_query("INSERT INTO messaggi (user_m,user_d,ogg,mess) VALUES ('$this->user_m','$this->user_d',$this->ogg','$this->mess')");
			echo "Messaggio inviato con successo a $this->user_d";
			}
		}
	}
$nomev = $_SESSION['nome'];
$dname = $_GET['nome'];
$mess = $_POST['mess'];
$ogg = $_POST['ogg'];
$oggetto = new pctmess($nomev,$dname,$ogg,$mess);
if (isset($_POST['conferma'])) {
$oggetto->invia();
} else {
echo "<form method=\"post\" action=\"$PHP_SELF\">";
echo "Mittente: $nomev<br>";
echo "Destinatario:$dname <br>";
echo "Oggetto: <input type=\"text\" name=\"ogg\"><br>";
echo "Testo:<br>";
echo "<textarea name=\"mess\"></textarea><br>";
echo "<input type=\"submit\" value=\"Invia\" name=\"conferma\">";
echo "</form>";
}
?>
</body>
</html>

ed ecco il codice SQL della tabella:
CREATE TABLE IF NOT EXISTS `messaggi` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_m` varchar(30) NOT NULL,
  `mess` text NOT NULL,
  `data` date NOT NULL,
  `user_d` varchar(30) NOT NULL,
  `ogg` varchar(30) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


Il problema è che mi viene fuori il messaggio "Messaggio inviato a (nomeutentedestinatario)" ma quando guardo nel db mi dice che non c'è niente.

Grazie in anticipo.
Ultima modifica effettuata da MillenniumBug 29/07/11 12:31
aaa
29/07/11 13:38
HeDo
per vedere se ti da errore la query aggiungi un "or die('errore')".

ad ogni modo prova a cambiare la sintassi della query in modo da utilizzare set al posto di values, potrebbe esserci qualche problema lì.
aaa