I add in the table (a DB I use ORACLE) the data in the form!
I send the date type data on the form.
How to convert string to date? Writes literal does not match the format!

private function save_project() { $id = $_POST['id_project']; $test_name = $_POST['name_project']; $emp_id = $_POST['emp_id']; $id_type = $_POST['id_type']; $time_result = $_POST['time_result']; $state = $_POST['state']; $date_close = $_POST['date_close']; $date = "to_date($date_close, 'dd.mm.yyyy')"; if($id == '0'){ $sql = "INSERT INTO PROJECT (ID, NAME, EMP_ID, ID_TYPE, TIME_RESULT, STATE, DATE_CLOSE) VALUES (SEQ_PROJECT.NEXTVAL, '$test_name', '$emp_id','$id_type', '$time_result', '$state', '$date')"; } else{ $sql = "update PROJECT set NAME = '$test_name', EMP_ID = '$emp_id', ID_TYPE = '$id_type', TIME_RESULT = '$time_result', STATE = '$state', DATE_CLOSE = '$date' where id = $id"; } $m = $this->db->Execute($sql); if($m !== true){ echo $m; return false; } header("Location: project"); } 

The error goes out such ORA-00917: missing comma

  • Show the minimum sample code and indicate where and when the error occurs. - default locale
  • $ date_close = $ _POST ['date_close']; $ date = "select to_date ($ date_close, 'dd.mm.yyyy') from Project"; if ($ id == '0') {$ sql = "INSERT INTO PROJECT (ID, NAME, EMP_ID, ID_TYPE, TIME_RESULT, STATE, DATE_CLOSE) VALUES (SEQ_PROJECT.NEXTVAL, $ test_name ',' $ emp_id ',' $ id_type ',' $ time_result ',' $ state ',' $ date ') "; } else {$ sql = "update PROJECT set NAME = '$ test_name', EMP_ID = '$ emp_id', ID_TYPE = '$ id_type', TIME_RESULT = '$ time_result', STATE = '$ state', DATE_CLOSE = '$ date 'where id = $ id "; } - Bahyt Abdisamat
  • I take all the data from the $ _POST array - Bahyt Abdisamat
  • error comes out such ORA-00917: missing comma - Bahyt Abdisamat
  • one
    We need to see how the query in $sql turned out before executing (outputting it to the logs or to the page) and trying to run it into Oracle (it doesn't matter via sqlplus / SQL Developer). If it is not clear after this, publish the query and on which line / position an error occurs. - default locale

0