PHP到Oracle日期警告

时间:2014-09-24 19:05:25

标签: php sql oracle warnings comma

我收到一个ORA-00917:在下面标记的行上缺少逗号警告,这表示我的查询中出现了这种情况。但是,我已经多次查询了我的查询,似乎无法找到这个“缺少逗号”。感谢您的时间。 “警告: oci_execute()[function.oci-execute]:ORA-00917:缺少逗号 在“

if(isset($_POST['submit']))
{
     $db = oci_connect('user', 'password, "server/host");
     $Notes = kFile($_POST["notes"]);
     if(empty($_POST["composite"])){$composite = "No";}else{$composite = "Yes";}
     $techName = $_POST['techName'];
     $setupDate = $_POST['setupdate'];
     $removalDate = $_POST['removaldate'];
     $startDate = $_POST['startdate'];
     $stopDate = $_POST['stopdate'];
     $sampleLocation = $_POST['samplelocation'];
     $serialN = $_POST['serialn'];
     $filterN = $_POST['filtern'];
     $initialFlow = $_POST['initialflow'];
     $timerStop = $_POST['timerstop'];
     $finalFlow = $_POST['finalflow'];  
     $timerStart = $_POST['timerstart'];
     $finalWeight = $_POST['finalweight'];
     $temperature = $_POST['temperature'];
     $initialWeight = $_POST['initialweight'];
     $atmPressure = $_POST['atmpressure'];
     $filterLoad = $_POST['filterload'];

     $query = "INSERT INTO DATA(
                                                TECHNICIAN_NAME,
                                                SAMPLE_LOCATION,
                                                SERIAL_NUM,
                                                FILTER_NUM,
                                                START_DATE,
                                                START_TIME,
                                                STOP_DATE,
                                                STOP_TIME,
                                                INITIAL_FLOW,
                                                FINAL_FLOW,
                                                TIMER_STOP,
                                                TIMER_START,
                                                FINAL_WEIGHT,
                                                INITIAL_WEIGHT,
                                                TEMPERATURE,
                                                ATM_PRESSURE,
                                                COMMENTS,
                                                NOT_IN_COMPOSITE,
                                                FILTER_LOAD,
                                                SET_UP_DATE,
                                                REMOVAL_DATE)
                                                VALUES(
                                                :name, :sample, :serial, :filter, TO_DATE(:startDate, 'mm/dd/yyyy'), TO_DATE(:startTime, 'mm/dd/yyyy'),
                                                TO_DATE(:stopDate, 'mm/dd/yyyy'), TO_DATE(:stopTime, 'mm/dd/yyyy'), :initialFlow, :finalFlow, :timerStop,
                                                :timerStart, :finalWeight, :initialWeight, :temperature, :atmPressure,
                                                :comments, :composite, :filterLoad, TO_DATE(:setup, 'mm/dd/yyyy'), TO_DATE(:removal, 'mm/dd/yyyy'))";

    $compiled = oci_parse($db, $query);

    oci_bind_by_name($compiled, ':name', $techName);
    oci_bind_by_name($compiled, ':sample', $sampleLocation);
    oci_bind_by_name($compiled, ':serial', $serialN);
    oci_bind_by_name($compiled, ':filter', $filterN);
    oci_bind_by_name($compiled, ':startDate', $startDate);
    oci_bind_by_name($compiled, ':startTime', $startDate); //redundant check db
    oci_bind_by_name($compiled, ':stopDate', $stopDate);
    oci_bind_by_name($compiled, ':stopTime', $stopDate); //redundant check db
    oci_bind_by_name($compiled, ':initialFlow', $initialFlow);
    oci_bind_by_name($compiled, ':finalFlow', $finalFlow);
    oci_bind_by_name($compiled, ':timerStop', $timerStop);
    oci_bind_by_name($compiled, ':timerStart', $timerStart);
    oci_bind_by_name($compiled, ':finalWeight', $finalWeight);
    oci_bind_by_name($compiled, ':initialWeight', $initialWeight);
    oci_bind_by_name($compiled, ':temperature', $temperature);
    oci_bind_by_name($compiled, ':atmPressure', $atmPressure);
    oci_bind_by_name($compiled, ':comments', $kosterNotes);
    oci_bind_by_name($compiled, ':composite', $composite);
    oci_bind_by_name($compiled, ':filterLoad', $filterLoad);
    oci_bind_by_name($compiled, ':setup', $setupDate);
    oci_bind_by_name($compiled, ':removal', $removalDate);

    oci_execute($compiled); //warning occurs here
    echo "Did I execute?";
}

感谢您的光临。

2 个答案:

答案 0 :(得分:0)

查看上述问题中突出显示的文字。然后查看设置密码的第三行代码。请注意,缺少单引号。任何好的代码编辑器都应该使这个问题变得明显。

答案 1 :(得分:0)

您似乎错过了查询中的最后一个括号;将VALUES列表括起来的那个:

$query = "INSERT INTO ... VALUES(..., TO_DATE(:removal, 'mm/dd/yyyy')";
                                    need one more parenthesis here  ^

修正:

$query = "INSERT INTO ... VALUES(..., TO_DATE(:removal, 'mm/dd/yyyy'))";
                                                         here it is  ^