I tried run the below code...
<?php
error_reporting(E_ERROR);
ini_set("display_errors", 1);
ini_set("memory_limit", "256M");
ini_set('max_execution_time', 0);
set_time_limit(0);
$filename = "mapp_cs1232.csv";
$dirloc = "/applics/feed/output/";
$fileloc = $dirloc . $filename;
// create a directory is not existed one
if (!file_exists($dirloc )) {
mkdir($dirloc , 0777);
}
$sql = "SELECT
H.ID AS Emplid,
H.SEMETER ,
H.TUITION,
H.YEAR,
H.START
FROM
APPPLIC H,
ENROLL_APPLS HA
WHERE
h.ID = HA.APPLID";
// connection
$conn = oci_connect('xe', '123456', '//192.168.1.55/xe');
$stmt = oci_parse($conn, $sql);
// CSV header file
$title_aa = array(
'Emplid',
'SEMESTER',
'Tuition',
'Year',
'Start'
);
// create a csv file
$fp = fopen($fileloc, 'w');
// write a CSV header file
fputcsv($fp, $title_aa);
// check for oracle
if (oci_execute($stmt)) {
loop through the record and write to the CSV file
while ($row = oci_fetch_array($stmt, OCI_ASSOC + OCI_RETURN_NULLS)) {
fputcsv($fp, array_change_key_case($row, CASE_LOWER));
}
}
// need to close the connection
// must free up all the memory
oci_free_statement($stmt);
oci_close($conn);
fclose($fp);
?>