I'm back again.... this is weird, I pput an echo statement near the bottom of my code, but it does not print, any ideas??? Here is my code:
<?php
$updir = "/usr/local/mysql/bin/datafiles"; //absolute path to where files are uploaded
$sizelim = "yes"; //do you want size limitations yes or no
$size = "25000"; //if you want size limited how many bytes
$certtype = "no"; //do you want certain type of file, no recommended
$type = ""; //what type of file would you like
//error if no file is selected
if ($file_name == "") {
die("No file selected to upload");
}
//error if file exists
if (file_exists("$updir/$file_name")) {
die("The file you are trying to upload already exists");
}
//error if file is to big
if ($sizelim == "yes") {
if ($file_size > $size) {
die("The file you are trying to upload is too big.");
}
}
//error if file isn't certain type
if ($certtype == "yes") {
if ($type != $file_type) {
die("The file you are trying to upload is wrong type");
}
}
@copy($file, "$updir/$file_name") or die("The file you are trying to upload couldn't be
copied to the server");
?>
<head>
<title>File Uploaded</title>
</head>
<body>
<p>
<?php
$dbname="mydb";
$dbhost="Schemp";
if (!($db = mysql_connect("localhost", "root")))
echo "error connecting to ". $dbname ."on ". $dbhost;
mysql_select_db($dbname,$db);
$content = file("/usr/local/mysql/bin/datafiles/test.txt");
$Counter=1;
while (list($key, $val) = each ($content))
{
if ($Counter>1)
{
$data = explode("\t", $val);
$NewUserSSN = $data[2];
$NewUserEmailArray= explode ("\n", $data[3]);
$NewUserEmail=$NewUserEmailArray[0];
$NewUserBearIDArray = split('[@]', $data[3]);
$NewUserBearID = $NewUserBearIDArray[0];
$bearid_result = mysql_query("select BearID from User where BearID='$NewUserBearID' ");
$num_bearid_records = mysql_num_rows($bearid_result);
if($num_bearid_records <1)
{
$BearIDFlag=FALSE;
} else
{
$BearIDFlag=TRUE;
}
$ssn_result = mysql_query("select SSN from User where SSN='$NewUserSSN' ");
$num_ssn_records = mysql_num_rows($ssn_result);
if ($num_ssn_records < 1)
{
$SSNFlag=FALSE;
} else
{
$SSNFlag=TRUE;
}
if (($BearIDFlag==TRUE)||($SSNFlag==TRUE))
{
$ssn_roster_result=mysql_query("select * from Roster where SSN = '$NewUserSSN' ");
$num_ssn_roster_records=mysql_num_rows($ssn_roster_result);
if ($num_ssn_roster_records < 1)
{
$SSNRosterFlag=FALSE;
} else
{
$SSNRosterFlag=TRUE;
}
$bearid_roster_result=mysql_query(" select * from Roster where Email='$data[3]' ");
$num_bearid_roster_records=mysql_num_rows($bearid_roster_result);
if ($num_bearid_roster_records < 1)
{
$BearIDRosterFlag=FALSE;
} else
{
$BearIDRosterFlag=TRUE;
}
if (($BearIDRosterFlag==TRUE)||($SSNRosterFlag==TRUE))
{
die("User already is in the Roster and User table!");
} else
{
$sql=sprintf("INSERT into Roster VALUES (NULL, '%s', '%s', '%s', '%s', '%s')",
$data[0], $data[1], $data[2], $NewUserEmail, $data[4], $data[5]);
}
}
if (($BearIDFlag==FALSE)&&($SSNFlag==FALSE))
{
//Add user to the user table, assumed to all be students
$AddUser="INSERT into User (ID, BearID, SSN, UserType) VALUES
(NULL, '$NewUserBearID', '$NewUserSSN', '$NewUserType')";
$AddUserResult=mysql_query($AddUser);
$error= mysql_error();
echo $error;
echo "<br>";
$ssn_roster_result=mysql_query("select from Roster where SSN='$NewUserSSN' ");
$num_ssn_roster_records=mysql_num_rows($ssn_roster_result);
if ($num_ssn_roster_records < 1)
{
$SSNRosterFlag=FALSE;
} else {
$SSNRosterFlag=TRUE; }
$bearid_roster_result=mysql_query(" select from Roster where Email = '$data[3]'");
$num_bearid_roster_records=mysql_num_rows($bearid_roster_result);
if ($num_bearid_roster_records <1)
{
$BearIDRosterFlag=FALSE;
} else {
$BearIDRoster=TRUE; }
if (($BearIDRosterFlag==TRUE)||($SSNRosterFlag==TRUE))
{
die ("User with BearID $BearID already is in Roster table!");
} else {
$sql= sprintf("INSERT into Roster VALUES (NULL, '%s', '%s', '%s', '%s')",
$data[0], $data[1], $data[2], $NewUserEmail, $data[4]);
}
$result = mysql_query($sql, $db);
}
}
$Counter++;
}
echo 'File successfullly uploaded and added to the database'; //doesnt print!
?>