Jump to content

[SOLVED] Inserting custom DATETIME into database error.


pocobueno1388

Recommended Posts

I have a DATETIME field in the database that I am trying to stick a value in but keep getting an error.

 

Here is my query:

$insert_item = "INSERT INTO auctions (`ownerID`, `type`, `typeID`, `reserve`, `start`, `end`, `description`, `start_price`) VALUES ('$sid', '$item_type', '$itemID', '$reserve', $start, $end, '$description', ' $start_price')";

 

Here is the error I get:

 

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 '15:43, 2007-03-14 15:43, 'Pink dragon for your tank.', ' 500')' at line 2

 

And when I echo the query, I get this:

INSERT INTO auctions (ownerID, type, typeID, reserve, start, end, description, start_price) VALUES ('-1', 'tankitem', '63570', '2000', 2007-03-10 15:43, 2007-03-14 15:43, 'Pink dragon for your tank.', ' 500')

 

This happened when I started entering the dates/times into the DB.

 

Any help is greatly appreciated, thanks =]

surround the date in # signs.

 

IE: '#03-04-2007 00:00:00#'

 

If it were me I wouldn't use the date/time field I would do it as an int of 11 and store the time() value in it, but if you want to look at the database like that periodically your way works to. To each his own.

 

--FrosT

EDIT: Hold on, I am an idiot...you can tell by my query, lmao.

 

Nope, that didn't work either =/

 

Here is the query I used:

$insert_item = "INSERT INTO auctions (`ownerID`, `type`, `typeID`, `reserve`, `#start#`, `#end#`, `description`, `start_price`) VALUES ('$sid', '$item_type', '$itemID', '$reserve', $start, $end, '$description', ' $start_price')";

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.