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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.