Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
PHP - Problema messaggistica interna sito
Forum - PHP - Problema messaggistica interna sito

Avatar
MillenniumBug (Member)
Rookie


Messaggi: 40
Iscritto: 08/04/2011

Segnala al moderatore
Postato alle 14:22
Venerdė, 29/07/2011
Ciao a tutti ho u problema nell'inserimento del messaggio di un utente ad un altro nel database.
Questo č il codice:
Codice sorgente - presumibilmente Php

  1. <html>
  2. <head>
  3. <title>Scrivi Messaggio</title>
  4. </head>
  5. <body>
  6. <?php
  7. include("conn.php");
  8. class pctmess {
  9.         public $user_m;
  10.         public $user_d;
  11.         public $ogg;
  12.         public $mess;
  13.                 public function __construct($m,$d,$o,$me) {
  14.                         $this->user_m = $m;
  15.                         $this->user_d = $d;
  16.                         $this->ogg = $o;
  17.                         $this->mess = $me;
  18.                 }
  19.                 public function invia() {
  20.                         if ($this->ogg == "" || $this->mess == "") {
  21.                                 echo "Inserisci oggetto o messaggio";
  22.                                 } else {
  23.                         mysql_query("INSERT INTO messaggi (user_m,user_d,ogg,mess) VALUES ('$this->user_m','$this->user_d',$this->ogg','$this->mess')");
  24.                         echo "Messaggio inviato con successo a $this->user_d";
  25.                         }
  26.                 }
  27.         }
  28. $nomev = $_SESSION['nome'];
  29. $dname = $_GET['nome'];
  30. $mess = $_POST['mess'];
  31. $ogg = $_POST['ogg'];
  32. $oggetto = new pctmess($nomev,$dname,$ogg,$mess);
  33. if (isset($_POST['conferma'])) {
  34. $oggetto->invia();
  35. } else {
  36. echo "<form method=\"post\" action=\"$PHP_SELF\">";
  37. echo "Mittente: $nomev<br>";
  38. echo "Destinatario:$dname <br>";
  39. echo "Oggetto: <input type=\"text\" name=\"ogg\"><br>";
  40. echo "Testo:<br>";
  41. echo "<textarea name=\"mess\"></textarea><br>";
  42. echo "<input type=\"submit\" value=\"Invia\" name=\"conferma\">";
  43. echo "</form>";
  44. }
  45. ?>
  46. </body>
  47. </html>


ed ecco il codice SQL della tabella:
Codice sorgente - presumibilmente Php

  1. CREATE TABLE IF NOT EXISTS `messaggi` (
  2.   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  3.   `user_m` varchar(30) NOT NULL,
  4.   `mess` text NOT NULL,
  5.   `data` date NOT NULL,
  6.   `user_d` varchar(30) NOT NULL,
  7.   `ogg` varchar(30) NOT NULL,
  8.   PRIMARY KEY (`id`)
  9. ) 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 il 29/07/2011 alle 14:31
PM
Avatar
HeDo (Founder Member)
Guru^2


Messaggi: 2765
Iscritto: 21/09/2007

Up
2
Down
V
Segnala al moderatore
Postato alle 15:38
Venerdė, 29/07/2011
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ė.

grazie mille hedo ho risolto infatti il problema era nella query - MillenniumBug - 29/07/11 19:22
di niente :) - HeDo - 30/07/11 02:16
PM