Jump to content

[SOLVED] date help.


jamesxg1

Recommended Posts

Hiya peeps,

 

I have this code,

 

<?php session_start();

     class UserInputs {
         
         private $compsub;
         private $compmes;
         private $dbusername;
         private $dbpassword;
         private $dbhost;
         private $dbbase;
         
      function __construct() {
          
          $this->randid = mt_rand();


      }
                                  
      function MYSQLConnection($dbusername = "root", $dbpassword = "", $dbhost = "localhost", $dbbase = "sli") {

          $this->dbusername = $dbusername;
          $this->dbpassword = $dbpassword;
          $this->dbhost = $dbhost;
          $this->dbbase = $dbbase;
          
          $this->MYSQLConnect = mysql_connect($this->dbhost, $this->dbusername, $this->dbpassword);
          $this->SelectDB = mysql_select_db($this->dbbase, $this->MYSQLConnect) or die(mysql_error());
          
          return($this->SelectDB); 
      }
  
      function Complain($compsub, $compmes) {
             
             $this->complainsubject = mysql_real_escape_string(addslashes($compsub));
             $this->complainmessage = mysql_real_escape_string(addslashes($compmes));
             $this->sesusername =     mysql_real_escape_string(addslashes($_SESSION['username']));
             $this->sesid =           mysql_real_escape_string(addslashes($_SESSION['id']));
             $this->randid =          mysql_real_escape_string(addslashes(mt_rand()));
             $this->date =            mysql_real_escape_string(addslashes(date("Y-m-d")));
             
             mysql_query("INSERT INTO `complaints` (`mid`, `id`, `username`, `date`, `subject`, `complaint`) VALUES('$this->sesid', '$this->randid', $this->sesusername', '$this->date', '$this->complainsubject', '$this->complainmessage')") or die(mysql_error());
             
             $compdone = "Complaint Added.";
             return $compdone;
         }
     }
?>

 

And im getting this error,

 

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 '', '2009-09-16', '', '')' at line 1

 

does anyone know why ?,

 

Many thanks,

 

James.

Link to comment
https://forums.phpfreaks.com/topic/170564-solved-date-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.