Jump to content

SQL not working, no idea why...


byrne86

Recommended Posts

OK, so iv got a form on a website, it inserts data into an SQL database,it was working until I added some more info to be put in - here is the php and error etc...

 

 

 

     $firstname = $_POST['firstname']; 
     $surname = $_POST['surname'];
 $email = $_POST['email'];
 $thisday = date(d);
 $thismonth = date(F);
 $thisyear = date(Y);
 $thishour = date(H);
 $thisminute = date(i);
 $thissecond = date(s);
 $thismicrosecond = date(u);

 

     $query = "INSERT INTO mydb (id, firstname, surname, email, day, month, year, hour, minute, second, microsecond) VALUES ('$Guid', '$firstname', '$surname', '$email', '$thisday', $thismonth', '$thisyear', '$thishour', '$thisminute', '$thissecond', '$thismicrosecond')";
     // execute query 
      $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); 

 

That is the php getting the data to put into the SQL database

 

Error in query: INSERT INTO mydb (id, firstname, surname, email, day, month, year, hour, minute, second, microsecond) VALUES ('7DD39B65-C369-7750-F77B-DB4904CCB5DE', 'skjdfhsk', 'sndhofsdi', 'oisdfosos', '28', October', '2010', '17', '10', '18', '000000'). 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 '', '2010', '17', '10', '18', '000000')' at line 1

 

That is the error I am getting... Can anyone tell me whatis wrong with this please.

 

As I said, it was working, but when I added everything from $thisday to $thismicrosecond inclusive this error was showing when I was trying to enter data into the DB

Link to comment
https://forums.phpfreaks.com/topic/217159-sql-not-working-no-idea-why/
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.