paulie Posted March 24, 2006 Share Posted March 24, 2006 I am attempting to enter information, typed into an HTML form, into an Oracle database. I have been able to do this successfully with the following code:$dsn = "odbc://$user:$pass@$host/$database"; $db = DB::connect($dsn); if(DB::isError($db)){ die ($db->getMessage()); } $table_name = 'engineers_worksheet';$fields_values = array( 'pk_worksheet_id' => $pk_no, 'unit_id' => $unitno, 'asset_name' => $regno, 'asset_make' => $makemod, 'customer' => $client, 'site_address' => $siteadd, 'asset_set_point_temp' => $celsius, 'asset_defrost_interval_hrs' => $defrost, 'unit_status' => $status, 'asset_condition' => $condition, 'lights_working_before' => $lightsb, 'lights_working_after' => $lightsa, 'asset_defects' => $defects, 'work_done' => $work, 'parts_used1' => $parts1, 'parts_used2' => $parts2, 'parts_used3' => $parts3, 'parts_used4' => $parts4, 'parts_used5' => $parts5, 'parts_used6' => $parts6, [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]'start_time' => $start,[!--colorc--][/span][!--/colorc--] [!--coloro:#CC0000--][span style=\"color:#CC0000\"][!--/coloro--]'end_time' => $finish,[!--colorc--][/span][!--/colorc--] 'engineer' => $psswd );$res = $db->autoExecute($table_name, $fields_values, DB_AUTOQUERY_INSERT);if (PEAR::isError($res)) { die($res->getMessage());}I have highlighted the start_time and end_time parts of the code because, although I have been successful in entering a date into the dataebase, I would also like a time value to be entered.Does anybody know of any way to format the variable, similar to SQL formatting of date and time, so that both date and time will be entered into the database? i.e. 'start_time' => ($start, 'DD-MON-YY HH24:MI:SS) Quote Link to comment Share on other sites More sharing options...
kanikilu Posted March 24, 2006 Share Posted March 24, 2006 You don't say what $start and $finish are, but this example assumes they are unix timestamps. If they are not, you'll need to either convert them or use something else because this won't work.[code]Array('start_time' => date('d-m-Y H:i:s', $start),'end_time' => date('d-m-Y H:i:s', $finish));[/code] Quote Link to comment Share on other sites More sharing options...
paulie Posted March 24, 2006 Author Share Posted March 24, 2006 thanks for the reply. The variables $start and $finish both contain the following data $time=time();$start=date("d-M-y G:i:s", time());I tried the code but it came back with an unknown DB error Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.