I posted before joining and am still waiting for moderator approval but I’ve gotten things to kind of work since then. So now I’m posting these errors and hoping to get some help to get this working. I did not write the code and know very little about writing php (or any language for that matter including english).
error on web page
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 1
error in logs
[Mon Feb 11 16:32:07 2013] [error] [client 66.205.141.237] PHP Notice: Undefined variable: TournName in /var/www/html/wrestling_dev/test/RosterBulk.php on line 27
[Mon Feb 11 16:32:07 2013] [error] [client 66.205.141.237] PHP Notice: Undefined variable: TournID in /var/www/html/wrestling_dev/test/RosterBulk.php on line 223
[Mon Feb 11 16:32:07 2013] [error] [client 66.205.141.237] PHP Notice: Undefined variable: ListSortBy in /var/www/html/wrestling_dev/test/RosterBulk.php on line 223
[php]<?
// Get config data OR throw error text
if (file_exists("…/inc/config.php")) {
include("…/inc/config.php");
} else {
$SiteName = “[Err: Config.php not found]”;
$SiteFooter = “© “.date(“Y”).””;
}
// Get school info
$queryString = “SELECT * FROM Schools
WHERE (ID
=”.$_SESSION[‘MySchool’].") AND ";
$queryString.= “(IsActive
=‘Y’) LIMIT 1;”;
$tournList = mysql_query($queryString, $_SESSION[‘MySqlConn’]) or die(mysql_error());
$row_schoolInfo = mysql_fetch_assoc($tournList);
$row_cnt = mysql_num_rows($tournList);
if ($row_cnt == 1) {
$SchoolName = $row_schoolInfo[‘SchoolName’];
$SchoolLocation = $row_schoolInfo[‘SchoolLocation’];
if ($row_schoolInfo[‘Coach1Name’] <> ‘’) {
$Coach1Info = $row_schoolInfo[‘Coach1Name’].’’;
if ($row_schoolInfo[‘Coach1Phone’]<>’’) {
$Coach1Info.= ’ {’.$row_schoolInfo[‘Coach1Phone’].’}’;
}
if ($row_schoolInfo[‘Coach1Email’]<>’’) {
$Coach1Info.= ’ [<a href=“mailto:’.$row_schoolInfo[‘Coach1Email’];
$Coach1Info.= ‘?Subject=’.$TournName.’” class=“gentxtSml”’;
$Coach1Info.= ‘title=“Click to email ‘.$row_schoolInfo[‘Coach1Name’].’”>’;
$Coach1Info.= $row_schoolInfo[‘Coach1Email’].’]
’;
}
} else { $Coach1Info = ‘’; }
if ($row_schoolInfo[‘Coach2Name’] <> ‘’) {
$Coach2Info = $row_schoolInfo[‘Coach2Name’].’’;
if ($row_schoolInfo[‘Coach2Phone’]<>’’) {
$Coach2Info.= ’ {’.$row_schoolInfo[‘Coach2Phone’].’}’;
}
if ($row_schoolInfo[‘Coach2Email’]<>’’) {
$Coach2Info.= ’ [<a href=“mailto:’.$row_schoolInfo[‘Coach2Email’];
$Coach2Info.= ‘?Subject=’.$TournName.’” class=“gentxtSml”’;
$Coach2Info.= ‘title=“Click to email ‘.$row_schoolInfo[‘Coach2Name’].’”>’;
$Coach2Info.= $row_schoolInfo[‘Coach2Email’].’]
’;
}
} else { $Coach2Info = ‘’; }
// If Coach “2” is currently primary, switch to coach “1”
if ($row_schoolInfo[‘UseCoach’] == 2) {
$tmp = $Coach1Info;
$Coach1Info = $Coach2Info;
$Coach2Info = $tmp;
}
} else {
$SchoolName = ‘Unknown School’;
$SchoolLocation = ‘Unknown Location’;
$Coach1Info = ‘’;
$Coach2Info = ‘’;
}
function ShowCell($stringText) {
if (strlen($stringText) > 0) {
return $stringText;
} else {
return " ";
}
}
$WrestlerFName = “”;
$WrestlerLName = “”;
$WrestlerWtClass = “”; // from $WtClass (TournConfig.php file) list
$WrestlerRank = “”; // A, B, C
$WrestlerSchool = “”; // If not logged in school
$Notes = “”;
$IsActive = “”;
$AddFormValidation = “”;
$AddFormCompletedOK = “”;
if ( (isset($_POST[‘FormSubmit’])) and ($_POST[‘FormSubmit’]==‘AddWrestlerBulk’) ) {
// Add school here (will be auto added to list of schools - must login)
$target_path = ‘tmpFiles/’;
if ($_FILES["CsvFileImport"]["error"] > 0) {
echo "Error: " . $_FILES["CsvFileImport"]["error"] . "<br>";
} else {
$target_path = $target_path . basename( $_FILES['CsvFileImport']['name']);
$csv = array();
$csvSkip = array();
$num = 0;
$name = $_FILES['CsvFileImport']['name'];
$ext = strtolower(end(explode('.', $_FILES['CsvFileImport']['name'])));
$type = $_FILES['CsvFileImport']['type'];
$tmpName = $_FILES['CsvFileImport']['tmp_name'];
// check the file is a csv
if($ext === 'csv'){
if(($handle = fopen($tmpName, 'r')) !== FALSE) {
// necessary if a large csv file
set_time_limit(0);
$row = 0; $rowSkip = 0;
while(($data = fgetcsv($handle, 0, ',')) !== FALSE) {
// number of fields in the csv
$num = count($data);
$WrLastName = trim($data[0], " ");
$WrFirstName = trim($data[1], " ");
$WgtClass = trim($data[2], " ");
$Rank = strtoupper(trim($data[3], " "));
$WrSchoolName = trim($data[4], " ");
$Notes = trim($data[5], " ");
$IsActive = strtoupper(trim($data[6], " "));
// Data defaults modifications
if (($Rank == "") or ($Rank == NULL)) {
$Rank = "A";
}
if (($IsActive <> "Y") and ($IsActive <> " N")) {
$IsActive = "N";
}
// Validate data
$error = "";
if (($WrLastName == "") or ($WrLastName == NULL)) {
if (strlen($error) > 0) { $error = $error . ", "; }
$error = $error . "Invalid Last Name";
}
if (($WrFirstName == "") or ($WrFirstName == NULL)) {
if (strlen($error) > 0) { $error = $error . ", "; }
$error = $error . "Invalid First Name";
}
if (($WgtClass == "") or ($WgtClass == NULL)) {
if (strlen($error) > 0) { $error = $error . ", "; }
$error = $error . "Invalid Weight Class";
}
if ((strtolower($Rank) <>"rank") and (strlen($Rank) <> 1)) {
if (strlen($error) > 0) { $error = $error . ", "; }
$error = $error . "Invalid Rank [A-Z]";
}
if (
(strtolower($WrLastName) == "wrestler last name") or
(strtolower($WrFirstName) == "wrestler first name") or
(strtolower($WgtClass) == "weight class") or
(strtolower($Rank) == "rank") or
(strtolower($WrSchoolName) == "school name") or
(strtolower($Notes) == "notes")
) {
// Skipped because it's the header
} elseif (strlen($error) > 0) {
$AddFormCompletedOK.= '<font color=RED>Record (<b>';
$AddFormCompletedOK.= stripslashes(trim($WrFirstName.' '.$WrLastName));
$AddFormCompletedOK.= '</b>) has been skipped for the following problems: <i>'.$error.'</i>.</font><br />';
} else {
// Write to database
$query_entry = "INSERT INTO `Wrestlers` (";
$query_entry.= "`TournID`, `SchoolID`, `WrestlerLName`, `WrestlerFName`, `WrestlerWtClass`, `WrestlerRank`, `WrestlerSchool`, `Notes`, `IsActive`, `AddDate`";
$query_entry.= ") VALUES (";
$query_entry.= $TournID.", ".$_SESSION['MySchool'].", '".addslashes($WrLastName)."', '".addslashes($WrFirstName)."', '".addslashes($WgtClass)."', '".addslashes($Rank)."', '".addslashes($WrSchoolName)."', '".addslashes($Notes)."', '".addslashes($IsActive)."', '".date("Y-m-d H:i:s")."'";
$query_entry.= ");";
$errtxt = "";
$writeme = mysql_query($query_entry, $_SESSION['MySqlConn']) or $errtxt=mysql_error();
if ($errtxt=="") {
$AddFormCompletedOK.= 'Your wrestler (<i>';
$AddFormCompletedOK.= stripslashes(trim($WrFirstName.' '.$WrLastName));
$AddFormCompletedOK.= '</i>) has been successfully added';
if ($IsActive == "N") { $AddFormCompletedOK.= " but <b>is inactive</b>"; }
$AddFormCompletedOK.= '.<br />';
} else {
$AddFormCompletedOK = '<b>Error:</b> This form currently cannot be processed. Please contact the tournament organizer or try again later.';
$AddFormCompletedOK.= '<br />{Error: '.$errtxt.'}<br />';
}
$row++;
}
}
fclose($handle);
}
}
}
}
echo ‘’;
// Display school info (show “edit” link)
echo ‘
’; echo ‘
echo ‘ | ’;||
Coach’; if (($Coach1Info <> ‘’) and ($Coach2Info <> ‘’)) { echo ‘es’; }
} |
’;
$queryString = “SELECT * FROM Wrestlers
WHERE “;
$queryString.= “(SchoolID
=’”.$_SESSION[‘MySchool’].”’) AND “;
$queryString.= “(TournID
=’”.$TournID.”’) ORDER BY “.$ListSortBy.”;”;
$wrestList = mysql_query($queryString, $_SESSION[‘MySqlConn’]) or die(mysql_error());
$row_wrestList = mysql_fetch_assoc($wrestList);
if ($AddFormCompletedOK <> “”) {
echo ‘
’; echo ‘
echo ‘ |
’;
} elseif ($AddFormValidation <> “”) {
echo ‘
’; echo ‘
echo ‘ |
’;
}
// Welcome message
echo ‘Welcome coach!
’;
/*
echo ‘’;
if (mysql_num_rows($wrestList) > 0) {
echo ‘Note: You currently have ‘;
echo mysql_num_rows($wrestList);
echo ’ wrestler’;
if (mysql_num_rows($wrestList) <> 1) { echo ‘s’; }
echo ’ currently on your roster.
’;
}
echo ‘
’;
*/
echo ‘’;
echo ‘You may upload your roster by using the blank template provided.
’;
echo ‘The chart below shows the currently registered wrestlers for your school.
’;
if (mysql_num_rows($wrestList) > 0) {
echo ‘To edit a wrestler, click the edit icon () next to their last name.
’;
}
echo ‘
’;
// Display list of wrestlers assoc to school
echo ‘
’; echo ‘’; echo ‘Last Name’; echo ‘’; if ($ListSortCol == “LName”) { echo ‘’; } echo ‘ | ’;’; echo ‘’; echo ‘First Name’; echo ‘’; if ($ListSortCol == “FName”) { echo '’; } echo ‘ | ’;’; echo ‘’; echo ‘Wt. Class’; echo ‘’; if ($ListSortCol == “WtClass”) { echo ‘’; } echo ‘ | ’;’; echo ‘’; echo ‘School’; echo ‘’; if ($ListSortCol == “School”) { echo '’; } echo ‘ | ’;’; echo ‘’; echo ‘Active’; echo ‘’; if ($ListSortCol == “Active”) { echo ‘*’; } echo ‘ | ’;
’; echo ‘’; echo ‘ echo ’ ‘; if ($row_wrestList[‘IsActive’] == “N”) { echo ‘ echo ‘’.$row_wrestList[‘WrestlerLName’].’’; if ($row_wrestList[‘IsActive’] == “N”) { echo ‘ echo ‘ | ’;’; if ($row_wrestList[‘IsActive’] == “N”) { echo ‘ echo ‘’.$row_wrestList[‘WrestlerFName’].’’; if ($row_wrestList[‘IsActive’] == “N”) { echo ‘ echo ‘ | ’;’; echo ‘’.$row_wrestList[‘WrestlerWtClass’].’ ‘.$row_wrestList[‘WrestlerRank’].’’; echo ‘ | ’;’; if ($row_wrestList[‘WrestlerSchool’] == “”) { echo ’ ‘; } echo ‘’.$row_wrestList[‘WrestlerSchool’].’’; echo ‘ | ’;<span title="’; if ($row_wrestList[‘IsActive’] == “N”) { echo ‘Not Active’; } else { echo ‘Active’; } echo ‘">’; echo $row_wrestList[‘IsActive’]; echo ‘ | ’;
’; echo ‘There are currently no wrestlers.’; echo ‘ |
echo ‘
’;
// Add new wrestler form
echo ‘’;
echo ‘’; // Set max file size (in bytes)
echo ‘
’; if ($AddFormValidation <> “”) { echo ‘’; echo ‘
} elseif ($row_cnt > 0) { echo ‘Note: Please check the list above for your wrestler before you use this form. If you upload a wrestler record multiple times, you will get duplicate records.’; } echo ‘ | |
Import Wrestlers | |
’; echo ‘ * = Required ’;echo ‘ | |
CSV file*: | |
’; echo ‘TID: ‘.$TournID.’’; echo ’ - '; echo ‘SID: ‘.$_SESSION[‘MySchool’].’’; echo ‘ | |
’; echo ‘[Enter wrestlers manually]’; echo ‘ |
echo ‘’;
echo ‘’;
echo ‘’;
?>[/php]