View Full Version : Combining Form Variables

11-10-2006, 10:01 PM
Okay, hopefully this is an easy one. I have a form on which a user can select a date in one field and a time in another. I need to combine these two variables into a single datetime variable to put in the database. I've looked all over and can't seem to find any good info on this. Everything else I am sending to the database works just fine.

Here is what doesn't work [it throws a parser error]:

$db_host = "*****";
$db_user = "*****";
$db_pwd = "*****";
$db_name = "contentdb";

mysql_connect($db_host, $db_user, $db_pwd) or die('Could not connect to mysql server: '. mysql_error());
mysql_select_db($db_name) or die('Could not select database: '. mysql_error());

$publishdatetime = $_GET["publishdate"] + $_GET["publishtime"];

$result = mysql_query("insert into main_articles (publishdatetime) values ('$publishdatetime');


11-10-2006, 10:25 PM
This should help:

http://www.developer.com/lang/php/article.php/938511 (http://www.developer.com/lang/php/article.php/938511)

11-10-2006, 10:27 PM
That's just what I needed. Thanks Scriptbanger. :thumbsup: