Hi, I'm in a class at UF where I have to build a website using PHP and Oracle...neither of which are taught in the class. So, I've had to start from scratch and learn on my own. One of the functions necessary for the site is to be able to bulk upload some data in the form of a .csv file into the oracle database.
I've written a script for it, but I can't get it to work. Since my knowledge of PHP is limited, and PHP doesn't have a compiler or any error checking, I don't know what the problem is. Here's the script, any help or pointing in the right direction would be VERY much appreciated:
#!/usr/local/bin/php
<?
//check if cookie is still valid
$AdminCookie = $HTTP_COOKIE_VARS["Admin"];
if ($AdminCookie=="PWGood"){
setcookie("Admin", "PWGood", time() + 600);
}
//$connection = ocilogon('username', 'password', 'orcl');
//gets the file//
$files = $_FILES['userfile']['tmp_name'];
if (file_exists($file_name))
{
$lines = file($files);
}
else
{
echo "Cannot find file";
}
foreach ($lines as $line_num => $line)
{
//first we'll get the professor's id//
$student_idlocal=strpos($line,"|");
$student_id=substr($line,0,$student_idlocal);
//first name//
$last_namelocal=strpos($line,"|",$student_idlocal+1);
$last_name=substr($line,$student_idlocal+1,($last_namelocal-$student_idlocal)-1);
//last name//
$first_namelocal=strpos($line,"|",$last_namelocal+1);
$first_name=substr($line,$last_namelocal+1,($first_namelocal-$last_namelocal)-1);
//Query to insert each professor into db//
$query1 = "INSERT INTO ROSTER VALUES ('$student_id','$last_name','$first_name')";
parse n' execute//
$results = OCIParse($connection,$query1);
$doquery1 = OCIExecute($results);
/tml confirmation of upload//
echo "<p>$last_name, $first_name</p>";
$url = "http://www.cise.ufl.edu/~rmoyer"; // target of the redirect
$delay = "3"; // 3 second delay
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
}
?>