";
echo i18n("%1 (Grades %2-%3)",array(i18n($r->category),$r->mingrade,$r->maxgrade));
@@ -171,9 +172,10 @@ echo " \n";
echo "\n";
//query all of the categories
- $q=mysql_query("SELECT * FROM projectdivisions WHERE year='{$config['FAIRYEAR']}' ORDER BY division");
+ $q=$pdo->prepare("SELECT * FROM projectdivisions WHERE year='{$config['FAIRYEAR']}' ORDER BY division");
+ $q->execute();
$first = true;
- while($r=mysql_fetch_object($q)) {
+ while($r=$q->fetch(PDO::FETCH_OBJ)) {
$trclass = ($trclass == 'odd') ? 'even' : 'odd';
if($first == true) {
@@ -198,8 +200,9 @@ echo " \n";
//only show the sub-divisions if the 'main' division is scored >=3
if($u['div_prefs'][$r->id]>=3) {
- $subq=mysql_query("SELECT * FROM projectsubdivisions WHERE projectdivisions_id='$r->id' AND year='".$config['FAIRYEAR']."' ORDER BY subdivision");
- while($subr=mysql_fetch_object($subq)) {
+ $subq=$pdo->prepare("SELECT * FROM projectsubdivisions WHERE projectdivisions_id='$r->id' AND year='".$config['FAIRYEAR']."' ORDER BY subdivision");
+ $subq->execute();
+ while($subr=$subq->fetch(PDO::FETCH_OBJ)) {
echo "";
echo " ";
$ch = ($u['div_prefs_sub'][$subr->id]) ? "checked=\"checked\"" : '';
diff --git a/judge_main.php b/judge_main.php
index 6fe35ea..5fd91d6 100644
--- a/judge_main.php
+++ b/judge_main.php
@@ -49,8 +49,9 @@
$scheduleok=false;
if($config['dates']['judgescheduleavailable'] && $config['dates']['judgescheduleavailable']!="0000-00-00 00:00:00") {
- $q=mysql_query("SELECT (NOW()>'".$config['dates']['judgescheduleavailable']."') AS test");
- $r=mysql_fetch_object($q);
+ $q=$pdo->prepare("SELECT (NOW()>'".$config['dates']['judgescheduleavailable']."') AS test");
+ $q->execute();
+ $r=$q->fetch(PDO::FETCH_OBJ);
$scheduleok=$r->test;
}
else {
@@ -61,9 +62,10 @@
/* Check for any judging team assignment this year for this judge,
* if there is one, print the judge scheule link in an obvious place,
* it's less obvious below */
- $q = mysql_query("SELECT id FROM judges_teams_link WHERE
+ $q = $pdo->prepare("SELECT id FROM judges_teams_link WHERE
users_id='{$u['id']}' AND year='{$config['FAIRYEAR']}'");
- if(mysql_num_rows($q) > 0) {
+ $q2->execute();
+ if($q2->rowCount() > 0) {
echo '';
echo i18n("You have been assigned to a judging team. %1Click here%2 to view the judging schedule",
array(""," "));
diff --git a/judge_other.php b/judge_other.php
index 4ab87df..3aa60d3 100644
--- a/judge_other.php
+++ b/judge_other.php
@@ -62,7 +62,7 @@ case 'save':
$u['years_regional'] = intval($_POST['years_regional']);
$u['years_national'] = intval($_POST['years_national']);
$u['highest_psd'] = stripslashes($_POST['highest_psd']);
- $u['private_info'] = mysql_escape_string(iconv("UTF-8","ISO-8859-1//TRANSLIT",stripslashes($_POST['private_info'])));
+ $u['private_info'] = iconv("UTF-8","ISO-8859-1//TRANSLIT",stripslashes($_POST['private_info']));
//check if judge has been flagged then update them
@@ -130,9 +130,10 @@ echo "
\n";
=i18n("I can judge in the following languages")." ".REQUIREDFIELD?>:
-$q=mysql_query("SELECT * FROM languages WHERE active='Y' ORDER BY langname");
-echo mysql_error();
-while($r=mysql_fetch_object($q))
+$q=$pdo->prepare("SELECT * FROM languages WHERE active='Y' ORDER BY langname");
+$q->execute();
+echo $pdo->errorInfo();
+while($r=$q->fetch(PDO::FETCH_OBJ))
{
$ch = (in_array($r->lang,$u['languages'])) ? 'checked="checked"' : '';
echo " lang\" /> $r->langname ";
diff --git a/judge_project_summary.php b/judge_project_summary.php
index e8f07d9..4fafa63 100644
--- a/judge_project_summary.php
+++ b/judge_project_summary.php
@@ -27,29 +27,31 @@ require_once('user.inc.php');
user_auth_required(array('judge', 'committee'));
-$pn = mysql_escape_string(stripslashes($_GET['pn']));
+$pn = stripslashes($_GET['pn']);
-$q=mysql_query("SELECT * FROM projects WHERE
+$q=$pdo->prepare("SELECT * FROM projects WHERE
projectnumber='$pn'
AND year='{$config['FAIRYEAR']}'");
-if(mysql_num_rows($q)==0) {
+$q->execute();
+if($q->rowCount()==0) {
echo "not found";
exit;
}
-$pi = mysql_fetch_object($q);
+$pi = $q->fetch(PDO::FETCH_OBJ);
-$sq = mysql_query("SELECT firstname,lastname,school FROM students
+$sq = $pdo->prepare("SELECT firstname,lastname,school FROM students
LEFT JOIN schools ON schools.id = students.schools_id
WHERE
registrations_id='{$pi->registrations_id}'
AND students.year='{$config['FAIRYEAR']}'");
+$sq->execute();
$student = array();
-while($si = mysql_fetch_object($sq)) {
+while($si = $sq->fetch(PDO;;FETCH_OBJ)) {
$student[] = $si->firstname.' '.$si->lastname;
$school = $si->school;
}
diff --git a/judge_schedule.php b/judge_schedule.php
index d11bf13..e33abd0 100644
--- a/judge_schedule.php
+++ b/judge_schedule.php
@@ -54,8 +54,9 @@ $u = user_load($eid);
$scheduleok=false;
if($config['dates']['judgescheduleavailable'] && $config['dates']['judgescheduleavailable']!="0000-00-00 00:00:00") {
- $q=mysql_query("SELECT (NOW()>'".$config['dates']['judgescheduleavailable']."') AS test");
- $r=mysql_fetch_object($q);
+ $q=$pdo->prepare("SELECT (NOW()>'".$config['dates']['judgescheduleavailable']."') AS test");
+ $q->execute();
+ $r=$q->fetch(PDO::FETCH_OBJ);
$scheduleok=$r->test;
}
else {
@@ -72,46 +73,51 @@ if(!$scheduleok) {
/* Find all judging teams this judge is on */
-$q = mysql_query("SELECT * FROM judges_teams_link
+$q = $pdo->prepare("SELECT * FROM judges_teams_link
LEFT JOIN judges_teams ON judges_teams.id=judges_teams_link.judges_teams_id
WHERE judges_teams_link.users_id='{$u['id']}'
AND judges_teams_link.year='{$config['FAIRYEAR']}'");
+$q->execute();
$teams = array();
-while($t = mysql_fetch_assoc($q)) {
+while($t = $q->fetch(PDO::FETCH_ASSOC)) {
/* Load timeslot data for this team (team -> judges_timeslots_link -> timeslot -> parent timeslot */
- $qq = mysql_query("SELECT T.* FROM judges_teams_timeslots_link
+ $qq = $pdo->prepare("SELECT T.* FROM judges_teams_timeslots_link
LEFT JOIN judges_timeslots ON judges_timeslots.id=judges_teams_timeslots_link.judges_timeslots_id
LEFT JOIN judges_timeslots AS T ON T.id=judges_timeslots.round_id
WHERE judges_teams_timeslots_link.judges_teams_id={$t['judges_teams_id']}");
- $tt = mysql_fetch_assoc($qq);
- echo mysql_error();
+ $qq->execute();
+ $tt = $qq->fetch(PDO::FETCH_ASSOC);
+ echo $pdo->errorInfo();
$t['timeslot'] = $tt;
/* Load award */
- $qq = mysql_query("SELECT award_awards.*,T.type FROM judges_teams_awards_link
+ $qq = $pdo->prepare("SELECT award_awards.*,T.type FROM judges_teams_awards_link
LEFT JOIN award_awards ON award_awards.id=judges_teams_awards_link.award_awards_id
LEFT JOIN award_types as T ON T.id=award_awards.award_types_id
WHERE judges_teams_awards_link.judges_teams_id={$t['judges_teams_id']}");
- echo mysql_error();
- $aa = mysql_fetch_assoc($qq);
+ $qq->execute();
+ echo $pdo->errorInfo();
+ $aa = $qq->fetch(PDO::FETCH_ASSOC);
$t['award'] = $aa;
/* Load team members */
- $qq = mysql_query("SELECT * FROM judges_teams_link
+ $qq = $pdo->prepare("SELECT * FROM judges_teams_link
LEFT JOIN users ON users.id=judges_teams_link.users_id
WHERE judges_teams_link.judges_teams_id={$t['judges_teams_id']}
ORDER BY judges_teams_link.captain,users.lastname,users.firstname");
+ $qq->execute();
$t['members'] = array();
- while(($mm = mysql_fetch_assoc($qq))) {
+ while(($mm = $qq->fetch(PDO::FETCH_ASSOC)) {
$t['members'][] = $mm;
}
/* Load projects */
- $qq = mysql_query("SELECT projects.id,projects.projectnumber,projects.title FROM judges_teams_timeslots_projects_link
+ $qq = $do->prepare("SELECT projects.id,projects.projectnumber,projects.title FROM judges_teams_timeslots_projects_link
LEFT JOIN projects ON projects.id=judges_teams_timeslots_projects_link.projects_id
WHERE judges_teams_id={$t['judges_teams_id']}");
+ $qq->execute();
$p = array();
- while(($pp = mysql_fetch_assoc($qq)))
+ while(($pp = $qq->fetch(PDO::FETCH_ASSOC)))
$p[] = $pp;
/* If no project and it's a special award, get all nominated */
if(count($p) == 0 && $aa['type'] == 'Special') {
diff --git a/judge_special_awards.php b/judge_special_awards.php
index 66032ee..d3ab6fb 100644
--- a/judge_special_awards.php
+++ b/judge_special_awards.php
@@ -45,12 +45,14 @@ $u = user_load($eid);
switch($_GET['action']) {
case 'save':
//first delete all their old associations for this year..
- mysql_query("DELETE FROM judges_specialaward_sel WHERE users_id='{$u['id']}'");
+ $stmt = $pdo->prepare("DELETE FROM judges_specialaward_sel WHERE users_id='{$u['id']}'");
+ $stmt->execute();
if(array_key_exists('spaward', $_POST)) {
foreach($_POST['spaward'] AS $aid) {
- mysql_query("INSERT INTO judges_specialaward_sel (users_id, award_awards_id)
+ $stmt = $pdo->prepare("INSERT INTO judges_specialaward_sel (users_id, award_awards_id)
VALUES ('{$u['id']}','$aid')");
+ $stmt->execute();
}
}
happy_("Special Award preferences successfully saved");
@@ -104,15 +106,16 @@ if($_SESSION['embed'] != true) {
echo " ";
echo " ";
- $q=mysql_query("SELECT * FROM judges_specialaward_sel WHERE users_id='{$u['id']}'");
+ $q=$pdo->prepare("SELECT * FROM judges_specialaward_sel WHERE users_id='{$u['id']}'");
+ $q->execute();
$spawards = array();
- while($r=mysql_fetch_object($q)) $spawards[] = $r->award_awards_id;
+ while($r=$q->fetch(PDO::FETCH_OBJ)) $spawards[] = $r->award_awards_id;
echo "\n";
//query all of the awards
- $q=mysql_query("SELECT award_awards.id,
+ $q=$pdo->prepare("SELECT award_awards.id,
award_awards.name,
award_awards.criteria,
sponsors.organization
@@ -128,8 +131,9 @@ if($_SESSION['embed'] != true) {
AND award_types.year='{$config['FAIRYEAR']}'
ORDER BY
name");
- echo mysql_error();
- while($r=mysql_fetch_object($q))
+$q->execute();
+ echo $pdo->errorInfo();
+ while($r=$q->fetch(PDO::FETCH_OBJ))
{
?>
diff --git a/projects.inc.php b/projects.inc.php
index 3149270..5c0bd63 100644
--- a/projects.inc.php
+++ b/projects.inc.php
@@ -26,7 +26,7 @@ function getProjectsEligibleForAward($award_id)
{
global $config;
- $prjq=mysql_query("SELECT
+ $prjq=$pdo->prepare("SELECT
award_awards.id,
award_awards_projectcategories.projectcategories_id,
award_awards_projectdivisions.projectdivisions_id,
@@ -50,8 +50,9 @@ function getProjectsEligibleForAward($award_id)
ORDER BY
projectsort
");
+ $prjq->execute();
$projects=array();
- while($prjr=mysql_fetch_object($prjq))
+ while($prjr=$prjq->fetch(PDO::FETCH_OBJ))
{
$projects[$prjr->projectnumber]=array(
"id"=>$prjr->projects_id,
@@ -67,7 +68,7 @@ function getLanguagesOfProjectsEligibleForAward($award_id)
{
global $config;
- $prjq=mysql_query("SELECT DISTINCT(projects.language) AS language
+ $prjq=$pdo->prepare("SELECT DISTINCT(projects.language) AS language
FROM
award_awards,
award_awards_projectcategories,
@@ -84,8 +85,9 @@ function getLanguagesOfProjectsEligibleForAward($award_id)
ORDER BY
language
");
+ $prjq->execute();
$languages=array();
- while($r=mysql_fetch_object($prjq)) {
+ while($r=$prjq->fetch(PDO::FETCH_OBJ)) {
if($r->language)
$languages[]=$r->language;
}
@@ -97,8 +99,9 @@ function getProjectsEligibleOrNominatedForAwards($awards_ids_array)
$projects=array();
foreach($awards_ids_array AS $award_id)
{
- $q=mysql_query("SELECT award_types.type FROM award_awards, award_types WHERE award_awards.id='$award_id' AND award_awards.award_types_id=award_types.id");
- $r=mysql_fetch_object($q);
+ $q=$pdo->prepare("SELECT award_types.type FROM award_awards, award_types WHERE award_awards.id='$award_id' AND award_awards.award_types_id=award_types.id");
+ $q->execute();
+ $r=$q->fetch(PDO::FETCH_OBJ);
$awardprojects=array();
@@ -123,7 +126,7 @@ function getSpecialAwardsEligibleForProject($projectid)
{
global $config;
- $awardsq=mysql_query("SELECT
+ $awardsq=$pdo->prepare("SELECT
award_awards.id,
award_awards.name,
award_awards.criteria,
@@ -142,7 +145,7 @@ function getSpecialAwardsEligibleForProject($projectid)
AND award_types.id=award_awards.award_types_id
AND award_awards.id=award_awards_projectcategories.award_awards_id
AND award_awards.id=award_awards_projectdivisions.award_awards_id
- AND projects.projectcategories_id=award_awards_projectcategories.projectcategories_id
+ AND projects.projectcategories_ipreparequeryd=award_awards_projectcategories.projectcategories_id
AND projects.projectdivisions_id=award_awards_projectdivisions.projectdivisions_id
AND award_awards.id is not null
AND projects.year='".$config['FAIRYEAR']."'
@@ -152,9 +155,10 @@ function getSpecialAwardsEligibleForProject($projectid)
ORDER BY
award_awards.name
");
+ $awardsq->execute();
$awards=array();
- echo mysql_error();
- while($r=mysql_fetch_object($awardsq))
+ echo $pdo->errorInfo();
+ while($r=$awardsq->fetch(PDO::FETCH_OBJ))
{
$awards[$r->id]=array(
"id"=>$r->id,
@@ -170,7 +174,7 @@ function getSpecialAwardsNominatedForProject($projectid)
{
global $config;
- $awardsq=mysql_query("SELECT
+ $awardsq=$pdo->prepare("SELECT
award_awards.id,
award_awards.name,
award_awards.criteria,
@@ -188,9 +192,10 @@ function getSpecialAwardsNominatedForProject($projectid)
ORDER BY
award_awards.name
");
+ $awardsq->execute();
$awards=array();
- echo mysql_error();
- while($r=mysql_fetch_object($awardsq))
+ echo $pdo->errorInfo();
+ while($r=$awardsq->fetch(PDO::FETCH_OBJ))
{
$awards[$r->id]=array(
"id"=>$r->id,
@@ -205,7 +210,7 @@ function getSpecialAwardsNominatedForProject($projectid)
function getNominatedForNoSpecialAwardsForProject($projectid)
{
global $config;
- $awardsq=mysql_query("SELECT
+ $awardsq=$pdo->prepare("SELECT
projects.id AS projects_id
FROM
project_specialawards_link,
@@ -216,7 +221,8 @@ function getNominatedForNoSpecialAwardsForProject($projectid)
AND projects.id='$projectid'
AND project_specialawards_link.award_awards_id IS NULL
");
- if(mysql_num_rows($awardsq) == 1) return true;
+ $awardsq->execute();
+ if($awardsq->rowCount() == 1) return true;
return false;
}
@@ -228,7 +234,7 @@ function getProjectsNominatedForSpecialAward($award_id)
//are eligible for the award, instead of nominated for it.
if($config['specialawardnomination']!="none")
{
- $prjq=mysql_query("SELECT
+ $prjq=$pdo->prepare("SELECT
projects.projectnumber,
projects.title,
projects.language,
@@ -244,8 +250,9 @@ function getProjectsNominatedForSpecialAward($award_id)
ORDER BY
projectsort
");
+ $prjq->execute();
$projects=array();
- while($prjr=mysql_fetch_object($prjq))
+ while($prjr=$prjq->fetch(PDO::FETCH_OBJ))
{
$projects[$prjr->projectnumber]=array(
"id"=>$prjr->projects_id,
@@ -271,7 +278,7 @@ function getLanguagesOfProjectsNominatedForSpecialAward($award_id)
//if they dont use special award nominations, then we will instead get all of the projects that
//are eligible for the award, instead of nominated for it.
if($config['specialawardnomination']!="none") {
- $prjq=mysql_query("SELECT DISTINCT(projects.language) AS language
+ $prjq=$pdo->prepare("SELECT DISTINCT(projects.language) AS language
FROM
project_specialawards_link,
projects
@@ -282,8 +289,9 @@ function getLanguagesOfProjectsNominatedForSpecialAward($award_id)
AND projects.year='".$config['FAIRYEAR']."'
ORDER BY language
");
+ $prjq->execute();
$languages=array();
- while($r=mysql_fetch_object($prjq)) {
+ while($r=$prjq->fetch(PDO::FETCH_OBJ)) {
//dont count "" as a language, if the project doesnt have a language specified too bad they're up shit creek without a paddle
if($r->langauge) {
$languages[]=$r->language;
@@ -302,7 +310,7 @@ function getSpecialAwardsNominatedByRegistrationID($id)
{
global $config;
- $awardq=mysql_query("SELECT
+ $awardq=$pdo->prepare("SELECT
award_awards.id,
award_awards.name,
award_awards_projectcategories.projectcategories_id,
@@ -324,8 +332,9 @@ function getSpecialAwardsNominatedByRegistrationID($id)
ORDER BY
projectsort
");
+ $awardq->execute();
$projects=array();
- while($prjr=mysql_fetch_object($prjq))
+ while($prjr=$prjq->fetch(PDO::FETCH_OBJ))
{
$projects[$prjr->projectnumber]=array(
"id"=>$prjr->projects_id,
@@ -340,15 +349,17 @@ function getSpecialAwardsNominatedByRegistrationID($id)
function project_load($pid)
{
/* Load this project */
- $q = mysql_query("SELECT * FROM projects WHERE id='$pid'");
- $proj = mysql_fetch_array($q);
+ $q = $pdo->prepare("SELECT * FROM projects WHERE id='$pid'");
+ $q->execute();
+ $proj = $q->fetch();
/* Load the students */
- $q = mysql_query("SELECT students.*,schools.school FROM students
+ $q = $pdo->prepare("SELECT students.*,schools.school FROM students
LEFT JOIN schools ON schools.id=students.schools_id
WHERE registrations_id='{$proj['registrations_id']}' AND students.year='{$proj['year']}' ORDER BY students.id");
+ $q->execute();
$proj['num_students'] = 0;
- while($s = mysql_fetch_assoc($q)) {
+ while($s = $q->fetch(PDO::FETCH_OBJ)) {
$proj['num_students']++;
$proj['student'][] = $s;
}
diff --git a/questions.inc.php b/questions.inc.php
index 72b1375..5fd98d6 100644
--- a/questions.inc.php
+++ b/questions.inc.php
@@ -27,13 +27,15 @@
function questions_load_answers($section, $users_id)
{
global $config;
- $yearq=mysql_query("SELECT `year` FROM users WHERE id='$users_id'");
- $yearr=mysql_fetch_object($yearq);
+ $yearq=$pdo->prepare("SELECT `year` FROM users WHERE id='$users_id'");
+ $yearq->execute();
+ $yearr=$yearq->fetch(PDO::FETCH_OBJ);
$ans=array();
$qs=questions_load_questions($section,$yearr->year);
foreach($qs AS $id=>$question) {
- $q=mysql_query("SELECT * FROM question_answers WHERE users_id='$users_id' AND questions_id='$id'");
- $r=mysql_fetch_object($q);
+ $q=$pdo->prepare("SELECT * FROM question_answers WHERE users_id='$users_id' AND questions_id='$id'");
+ $q->execute();
+ $r=$q->fetch(PDO::FETCH_OBJ);
$ans[$id]=$r->answer;
}
return $ans;
@@ -67,29 +69,33 @@ function questions_save_answers($section, $id, $answers)
global $config;
$qs = questions_load_questions($section,$config['FAIRYEAR']);
$keys = array_keys($answers);
- $q=mysql_query("SELECT * FROM questions WHERE year='{$config['FAIRYEAR']}'");
- while($r=mysql_fetch_object($q)) {
- mysql_query("DELETE FROM question_answers WHERE users_id='$id' AND questions_id='$r->id'");
- echo mysql_error();
+ $q=$pdo->prepare("SELECT * FROM questions WHERE year='{$config['FAIRYEAR']}'");
+ $q->execute();
+ while($r=$q->fetch(PDO::FETCH_OBJ)) {
+ $stmt = $pdo->prepare("DELETE FROM question_answers WHERE users_id='$id' AND questions_id='$r->id'");
+ $stmt->execute();
+ echo $pdo->errorInfo();
}
$keys = array_keys($answers);
foreach($keys as $qid) {
/* Poll key */
- mysql_query("INSERT INTO question_answers
+ $stmt = $pdo->prepare("INSERT INTO question_answers
(users_id,questions_id,answer) VALUES(
'$id','$qid',
- '".mysql_escape_string($answers[$qid])."')" );
+ '".$answers[$qid]."')" );
+ $stmt->execute();
}
}
function questions_find_question_id($section, $dbheading)
{
- $q = mysql_query("SELECT id FROM questions WHERE ".
+ $q = $pdo->prepare("SELECT id FROM questions WHERE ".
" section='$section' ".
" AND db_heading='$dbheading' ");
- if(mysql_num_rows($q) == 1) {
- $r = mysql_fetch_object($q);
+ $q->execute();
+ if($q->rowCount() == 1) {
+ $r = $q->fetch(PDO::FETCH_OBJ);
return $r->id;
}
return 0;
@@ -162,28 +168,30 @@ function questions_parse_from_http_headers($array_name)
function questions_update_question($qs)
{
- mysql_query("UPDATE questions SET
- `question`='".mysql_escape_string($qs['question'])."',
- `type`='".mysql_escape_string($qs['type'])."',
- `db_heading`='".mysql_escape_string($qs['db_heading'])."',
- `required`='".mysql_escape_string($qs['required'])."',
- `ord`=".intval($qs['ord'])."
+ $stmt = $pdo->prepare("UPDATE questions SET
+ `question`='".$qs['question']."',
+ `type`='".$qs['type']."',
+ `db_heading`='".$qs['db_heading']."',
+ `required`='".$qs['required']."',
+ `ord`=".intval($qs['ord']."
WHERE id='{$qs['id']}' ");
- echo mysql_error();
+ $stmt->execute();
+ echo $pdo->errorInfo();
}
function questions_save_new_question($qs, $year)
{
- mysql_query("INSERT INTO questions ".
+ $stmt = $pdo->prepare("INSERT INTO questions ".
"(question,type,section,db_heading,required,ord,year) VALUES (".
- "'".mysql_escape_string($qs['question'])."',".
- "'".mysql_escape_string($qs['type'])."',".
- "'".mysql_escape_string($qs['section'])."',".
- "'".mysql_escape_string($qs['db_heading'])."',".
- "'".mysql_escape_string($qs['required'])."',".
- "'".mysql_escape_string($qs['ord'])."',".
+ "'".$qs['question']."',".
+ "'".$qs['type']."',".
+ "'".$qs['section']."',".
+ "'".$qs['db_heading']."',".
+ "'".$qs['required']."',".
+ "'".$qs['ord']."',".
"'$year' )");
- echo mysql_error();
+ $stmt->execute();
+ echo $pdo->errorInfo();
}
@@ -231,7 +239,8 @@ function questions_editor($section, $year, $array_name, $self)
$qs = questions_load_questions($section, $year);
/* Delete this question */
- mysql_query("DELETE FROM questions WHERE id='$qid'");
+ $stmt = $pdo->prepare("DELETE FROM questions WHERE id='$qid'");
+ $stmt->execute();
/* Update the order of all questions after this one */
$keys = array_keys($qs);
@@ -239,7 +248,8 @@ function questions_editor($section, $year, $array_name, $self)
if($q == $qid) continue;
if($qs[$q]['ord'] > $qs[$qid]['ord']) {
$qs[$q]['ord']--;
- mysql_query("UPDATE questions SET ord='{$qs[$q]['ord']}' WHERE id='$q'");
+ $stmt = $pdo->prepare("UPDATE questions SET ord='{$qs[$q]['ord']}' WHERE id='$q'");
+ $stmt->execute();
}
}
echo happy(i18n("Question successfully removed"));
@@ -248,18 +258,20 @@ function questions_editor($section, $year, $array_name, $self)
if($_GET['action']=="import" && $_GET['impyear'])
{
$x=0;
- $q = mysql_query("SELECT * FROM questions WHERE year='{$_GET['impyear']}'");
- while($r=mysql_fetch_object($q)) {
+ $q = $pdo->prepare("SELECT * FROM questions WHERE year='{$_GET['impyear']}'");
+ $q->execute();
+ while($r=$q->fetch(PDO::FETCH_OBJ)) {
$x++;
- mysql_query("INSERT INTO questions (id,year,section,db_heading,question,type,required,ord)
+ $stmt = $pdo->prepare("INSERT INTO questions (id,year,section,db_heading,question,type,required,ord)
VALUES (
'', '$year',
- '".mysql_escape_string($r->section)."',
- '".mysql_escape_string($r->db_heading)."',
- '".mysql_escape_string($r->question)."',
- '".mysql_escape_string($r->type)."',
- '".mysql_escape_string($r->required)."',
- '".mysql_escape_string($r->ord)."')");
+ '".$r->section."',
+ '".$r->db_heading."',
+ '".$r->question."',
+ '".$r->type."',
+ '".$r->required."',
+ '".$r->ord)."')";
+ $stmt->execute();
}
echo happy(i18n("%1 question(s) successfully imported",
@@ -305,7 +317,8 @@ function questions_editor($section, $year, $array_name, $self)
if($qdir != 0) {
$qs[$qid]['ord'] += $qdir;
/* Update the db */
- mysql_query("UPDATE questions SET ord='{$qs[$qid]['ord']}' WHERE id='$qid'");
+ $stmt = $pdo->prepare("UPDATE questions SET ord='{$qs[$qid]['ord']}' WHERE id='$qid'");
+ $stmt->execute();
$keys = array_keys($qs);
$originalq = $qs[$qid];
@@ -314,10 +327,12 @@ function questions_editor($section, $year, $array_name, $self)
if($qs[$q]['ord'] != $qs[$qid]['ord']) continue;
if($qdir == 1) {
$qs[$q]['ord']--;
- mysql_query("UPDATE questions SET ord='{$qs[$q]['ord']}' WHERE id='$q'");
+ $stmt = $pdo->prepare("UPDATE questions SET ord='{$qs[$q]['ord']}' WHERE id='$q'");
+ $stmt->execute();
} else {
$qs[$q]['ord']++;
- mysql_query("UPDATE questions SET ord='{$qs[$q]['ord']}' WHERE id='$q'");
+ $stmt = $pdo->prepare("UPDATE questions SET ord='{$qs[$q]['ord']}' WHERE id='$q'");
+ $stmt->execute();
}
/* Swap them so we don' thave to reaload the questions
* */
diff --git a/register_participants.inc.php b/register_participants.inc.php
index 7aefe90..0f3b613 100644
--- a/register_participants.inc.php
+++ b/register_participants.inc.php
@@ -26,8 +26,9 @@ function registrationFormsReceived($reg_id="")
{
if($reg_id) $rid=$reg_id;
else $rid=$_SESSION['registration_id'];
- $q=mysql_query("SELECT status FROM registrations WHERE id='$rid'");
- $r=mysql_fetch_object($q);
+ $q=$pdo->prepare("SELECT status FROM registrations WHERE id='$rid'");
+ $q->execute();
+ $r=$q->fetch(PDO::FETCH_OBJ);
if($r->status=="complete" || $r->status=="paymentpending")
return true;
else
@@ -37,8 +38,9 @@ function registrationFormsReceived($reg_id="")
function registrationDeadlinePassed()
{
global $config;
- $q=mysql_query("SELECT (NOW()<'".$config['dates']['regclose']."') AS datecheck");
- $datecheck=mysql_fetch_object($q);
+ $q=$pdo->prepare("SELECT (NOW()<'".$config['dates']['regclose']."') AS datecheck");
+ $q->execute();
+ $datecheck=$q->fetch(PDO::FETCH_OBJ);
if($datecheck->datecheck==1)
return false;
else
@@ -60,13 +62,13 @@ function studentStatus($reg_id="")
if($reg_id) $rid=$reg_id;
else $rid=$_SESSION['registration_id'];
- $q=mysql_query("SELECT * FROM students WHERE registrations_id='$rid' AND year='".$config['FAIRYEAR']."'");
-
+ $q=$pdo->prepare("SELECT * FROM students WHERE registrations_id='$rid' AND year='".$config['FAIRYEAR']."'");
+ $q->execute();
//if we dont have the minimum, return incomplete
- if(mysql_num_rows($q)<$config['minstudentsperproject'])
+ if($q->rowCount()<$config['minstudentsperproject'])
return "incomplete";
- while($r=mysql_fetch_object($q))
+ while($r=$q->fetch(PDO::FETCH_OBJ))
{
foreach ($required_fields AS $req)
{
@@ -95,14 +97,15 @@ function emergencycontactStatus($reg_id="")
if($reg_id) $rid=$reg_id;
else $rid=$_SESSION['registration_id'];
- $sq=mysql_query("SELECT id FROM students WHERE registrations_id='$rid' AND year='".$config['FAIRYEAR']."'");
- $numstudents=mysql_num_rows($sq);
+ $sq=$pdo->prepare("SELECT id FROM students WHERE registrations_id='$rid' AND year='".$config['FAIRYEAR']."'");
+ $sq->execute();
+ $numstudents=$sq->rowCount();
- while($sr=mysql_fetch_object($sq))
+ while($sr=$sq->fetch(PDO::FETCH_OBJ))
{
- $q=mysql_query("SELECT * FROM emergencycontact WHERE registrations_id='$rid' AND year='".$config['FAIRYEAR']."' AND students_id='$sr->id'");
-
- $r=mysql_fetch_object($q);
+ $q=$pdo->prepare("SELECT * FROM emergencycontact WHERE registrations_id='$rid' AND year='".$config['FAIRYEAR']."' AND students_id='$sr->id'");
+ $q->execute();
+ $r=$q->fetch(PDO::FETCH_OBJ);
foreach ($required_fields AS $req)
{
@@ -136,13 +139,13 @@ function projectStatus($reg_id="")
if($reg_id) $rid=$reg_id;
else $rid=$_SESSION['registration_id'];
- $q=mysql_query("SELECT * FROM projects WHERE registrations_id='$rid' AND year='".$config['FAIRYEAR']."'");
-
+ $q=$pdo->prepare("SELECT * FROM projects WHERE registrations_id='$rid' AND year='".$config['FAIRYEAR']."'");
+ $q->execute();
//if we dont have a project entry yet, return empty
- if(!mysql_num_rows($q))
+ if(!$q->rowCount())
return "empty";
- while($r=mysql_fetch_object($q))
+ while($r=$q->fetch(PDO::FETCH_OBJ))
{
foreach ($required_fields AS $req)
{
@@ -166,18 +169,20 @@ function mentorStatus($reg_id="")
else $rid=$_SESSION['registration_id'];
//first check the registrations table to see if 'nummentors' is set, or if its null
- $q=mysql_query("SELECT nummentors FROM registrations WHERE id='$rid' AND year='".$config['FAIRYEAR']."'");
- $r=mysql_fetch_object($q);
+ $q=$pdo->prepare("SELECT nummentors FROM registrations WHERE id='$rid' AND year='".$config['FAIRYEAR']."'");
+ $q->execute();
+ $r=$q->fetch(PDO::FETCH_OBJ);
if($r->nummentors==null)
return "incomplete";
- $q=mysql_query("SELECT * FROM mentors WHERE registrations_id='$rid' AND year='".$config['FAIRYEAR']."'");
+ $q=$pdo->prepare("SELECT * FROM mentors WHERE registrations_id='$rid' AND year='".$config['FAIRYEAR']."'");
+$q->execute();
//if we dont have the minimum, return incomplete
- if(mysql_num_rows($q)<$config['minmentorserproject'])
+ if($q->rowCount()<$config['minmentorserproject'])
return "incomplete";
- while($r=mysql_fetch_object($q))
+ while($r=$q->fetch(PDO::FETCH_OBJ))
{
foreach ($required_fields AS $req)
{
@@ -201,15 +206,17 @@ function safetyStatus($reg_id="")
else $rid=$_SESSION['registration_id'];
//grab all of their answers
- $q=mysql_query("SELECT * FROM safety WHERE registrations_id='$rid'");
- while($r=mysql_fetch_object($q))
+ $q=$pdo->prepare("SELECT * FROM safety WHERE registrations_id='$rid'");
+ $q->execute();
+ while($r=$q->fetch(PDO::FETCH_OBJ))
{
$safetyanswers[$r->safetyquestions_id]=$r->answer;
}
//now grab all the questions
- $q=mysql_query("SELECT * FROM safetyquestions WHERE year='".$config['FAIRYEAR']."' ORDER BY ord");
- while($r=mysql_fetch_object($q))
+ $q=$pdo->prepare("SELECT * FROM safetyquestions WHERE year='".$config['FAIRYEAR']."' ORDER BY ord");
+ $q->execute();
+ while($r=$q->fetch(PDO::FETCH_OBJ))
{
if($r->required=="yes" && !$safetyanswers[$r->id])
{
@@ -226,11 +233,12 @@ function spawardStatus($reg_id="")
if($reg_id) $rid=$reg_id;
else $rid=$_SESSION['registration_id'];
- $q=mysql_query("SELECT * FROM projects WHERE registrations_id='$rid'");
- $project=mysql_fetch_object($q);
+ $q=$pdo->prepare("SELECT * FROM projects WHERE registrations_id='$rid'");
+ $q->execute();
+ $project=$q->fetch(PDO::FETCH_OBJ);
/* We want this query to get any awards with a NULL award_awards_id */
- $awardsq=mysql_query("SELECT
+ $awardsq=$pdo->prepare("SELECT
projects.id AS projects_id
FROM
project_specialawards_link,
@@ -239,8 +247,9 @@ function spawardStatus($reg_id="")
project_specialawards_link.projects_id='".$project->id."'
AND projects.year='".$config['FAIRYEAR']."'
");
+ $awardsq->execute();
- if(mysql_num_rows($awardsq))
+ if($awardsq->rowCount())
return "complete";
else
return "incomplete";
@@ -254,19 +263,20 @@ function tourStatus($reg_id="")
else $rid=$_SESSION['registration_id'];
/* Get the students for this project */
- $q=mysql_query("SELECT * FROM students WHERE registrations_id='$rid' AND year='".$config['FAIRYEAR']."'");
- $num_found = mysql_num_rows($q);
+ $q=$pdo->prepare("SELECT * FROM students WHERE registrations_id='$rid' AND year='".$config['FAIRYEAR']."'");
+ $q->execute();
+ $num_found = $q->rowCount();
$ret = "complete";
- while($s=mysql_fetch_object($q)) {
+ while($s=$q->fetch(PDO::FETCH_OBJ)) {
//grab all of their tour prefs
$sid = $s->id;
- $qq=mysql_query("SELECT * FROM tours_choice WHERE students_id='$sid' and year='{$config['FAIRYEAR']}' ORDER BY rank");
-
- $n_tours = mysql_num_rows($qq);
+ $qq=$pdo->prepare("SELECT * FROM tours_choice WHERE students_id='$sid' and year='{$config['FAIRYEAR']}' ORDER BY rank");
+ $qq->execute();
+ $n_tours = $qq->rowCount();
if($n_tours > 0) {
/* See if there's a rank 0 tour (rank 0 == their tour assignment) */
- $i = mysql_fetch_object($qq);
+ $i = $qq->fetch(PDO::FETCH_OBJ);
if($i->rank == 0) {
/* Yes, there is, no matter what, this student's tour
* selection is complete. */
@@ -289,16 +299,18 @@ function namecheckStatus($reg_id="")
global $config;
if($reg_id) {
- $q=mysql_query("SELECT * FROM students WHERE
+ $q=$pdo->prepare("SELECT * FROM students WHERE
registrations_id='$reg_id'
+ $q->execute();
AND year='".$config['FAIRYEAR']."'");
} else {
- $q=mysql_query("SELECT * FROM students WHERE
+ $q=$pdo->prepare("SELECT * FROM students WHERE
id='{$_SESSION['students_id']}'");
- }
+ $q->execute();
+}
/* Get the students for this project */
- while($s=mysql_fetch_object($q)) {
+ while($s=$q->fetch(PDO::FETCH_OBJ)) {
if($s->namecheck_complete == 'no') {
return 'incomplete';
}
@@ -313,7 +325,7 @@ function generateProjectNumber($registration_id)
$reg_id = $registration_id;
- $q=mysql_query("SELECT projects.projectcategories_id,
+ $q=$pdo->prepare("SELECT projects.projectcategories_id,
projects.projectdivisions_id,
projectcategories.category_shortform,
projectdivisions.division_shortform
@@ -328,8 +340,9 @@ function generateProjectNumber($registration_id)
AND projectcategories.year='{$config['FAIRYEAR']}'
AND projectdivisions.year='{$config['FAIRYEAR']}'
");
- echo mysql_error();
- $r=mysql_fetch_object($q);
+ $q->execute();
+ echo $pdo->errorInfo();
+ $r=$q->fetch(PDO::FETCH_OBJ);
$p=array('number'=>array(), 'sort'=>array() );
$p['number']['str'] = $config['project_num_format'];
@@ -359,14 +372,15 @@ function generateProjectNumber($registration_id)
/* Build a total list of projects for finding a global number, and
* while constructing the list, build a list for the division/cat
* sequence number */
- $q = mysql_query("SELECT projectnumber_seq,projectsort_seq,
+ $q = $pdo->prepare("SELECT projectnumber_seq,projectsort_seq,
projectdivisions_id,projectcategories_id
FROM projects
WHERE year='{$config['FAIRYEAR']}'
AND projectnumber_seq!='0'
AND projectnumber IS NOT NULL");
- echo mysql_error();
- while($i = mysql_fetch_object($q)) {
+ $q->execute();
+ echo $pdo->errorInfo();
+ while($i = $q->fetch(PDO::FETCH_OBJ)) {
if( ($r->projectdivisions_id == $i->projectdivisions_id)
&&($r->projectcategories_id == $i->projectcategories_id) ) {
$p['number']['n_used'][] = $i->projectnumber_seq;
@@ -439,23 +453,26 @@ function computeRegistrationFee($regid)
$ret = array();
$regfee_items = array();
- $q = mysql_query("SELECT * FROM regfee_items
+ $q = $pdo->prepare("SELECT * FROM regfee_items
WHERE year='{$config['FAIRYEAR']}'");
- while($i = mysql_fetch_assoc($q)) $regfee_items[] = $i;
+ $q->execute();
+ while($i = $q->fetch(PDO::FETCH_ASSOC)) $regfee_items[] = $i;
- $q=mysql_query("SELECT * FROM students WHERE registrations_id='$regid' AND year='".$config['FAIRYEAR']."'");
- $n_students = mysql_num_rows($q);
+ $q=$pdo->prepare("SELECT * FROM students WHERE registrations_id='$regid' AND year='".$config['FAIRYEAR']."'");
+ $q->execute();
+ $n_students = $q->rowCount();
$n_tshirts = 0;
$sel = array();
- while($s = mysql_fetch_object($q)) {
+ while($s = $q->fetch(PDO::FETCH_OBJ)) {
if($s->tshirt != 'none') $n_tshirts++;
/* Check their regfee items too */
if($config['participant_regfee_items_enable'] != 'yes') continue;
- $sel_q = mysql_query("SELECT * FROM regfee_items_link
+ $sel_q = $pdo->prepare("SELECT * FROM regfee_items_link
WHERE students_id={$s->id}");
- while($info_q = mysql_fetch_assoc($sel_q)) {
+ $sel_q->execute();
+ while($info_q = $selq->fetch(PDO::FETCH_ASSOC)) {
$sel[] = $info_q['regfee_items_id'];
}
}
diff --git a/register_participants.php b/register_participants.php
index 2b83cd9..232c938 100644
--- a/register_participants.php
+++ b/register_participants.php
@@ -31,14 +31,19 @@
$datecheck = $q->fetch(PDO::FETCH_OBJ);
if($_POST['action']=="new") {
- $q=mysql_query("SELECT email,num,id,schools_id FROM registrations WHERE email='".$_SESSION['email']."' AND num='".$_POST['regnum']."' AND year=".$config['FAIRYEAR']);
- if(mysql_num_rows($q)) {
- $r=mysql_fetch_object($q);
+ $q=$pdo->prepare("SELECT email,num,id,schools_id FROM registrations WHERE email='".$_SESSION['email']."' AND num='".$_POST['regnum']."' AND year=".$config['FAIRYEAR']);
+ $q->execute();
+ if($q->rowCount()) {
+ $r=$q->fetch(PDO::FETCH_OBJ);
$_SESSION['registration_number']=$r->num;
$_SESSION['registration_id']=$r->id;
- mysql_query("INSERT INTO students (registrations_id,email,schools_id,year) VALUES ('$r->id','".mysql_escape_string($_SESSION['email'])."','".$r->schools_id."','".$config['FAIRYEAR']."')");
- mysql_query("UPDATE registrations SET status='open' WHERE id='$r->id'");
+ $stmt = $pdo->prepare("INSERT INTO students (registrations_id,email,schools_id,year) VALUES ('$r->id','".$_SESSION['email']."','".$r->schools_id."','".$config['FAIRYEAR']."')");
+
+ $stmt = $pdo->prepare("UPDATE registrations SET status='open' WHERE id='$r->id'");
+$stmt->execute();
+
+ $stmt->execute();
header("Location: register_participants_main.php");
exit;
@@ -52,17 +57,18 @@
}
else if($_POST['action']=="continue") {
if($_POST['email'])
- $_SESSION['email']=stripslashes(mysql_escape_string($_POST['email']));
+ $_SESSION['email']=stripslashes($_POST['email']);
- $q=mysql_query("SELECT registrations.id AS regid, registrations.num AS regnum, students.id AS studentid, students.firstname FROM registrations,students ".
+ $q=$pdo->prepare("SELECT registrations.id AS regid, registrations.num AS regnum, students.id AS studentid, students.firstname FROM registrations,students ".
"WHERE students.email='".$_SESSION['email']."' ".
"AND registrations.num='".intval($_POST['regnum'])."' ".
"AND students.registrations_id=registrations.id ".
"AND registrations.year=".$config['FAIRYEAR']." ".
"AND students.year=".$config['FAIRYEAR']);
+ $q->execute();
- if(mysql_num_rows($q)) {
- $r=mysql_fetch_object($q);
+ if($q->rowCount()) {
+ $r=$q->fetch(PDO::FETCH_OBJ);
$_SESSION['registration_number']=$r->regnum;
$_SESSION['registration_id']=$r->regid;
$_SESSION['students_id']=$r->studentid;
@@ -78,24 +84,26 @@
}
else if($_GET['action']=="resend" && $_SESSION['email']) {
//first see if the email matches directly from the registrations table
- $q=mysql_query("SELECT registrations.num FROM
+ $q=$pdo->prepare("SELECT registrations.num FROM
registrations
WHERE
registrations.email='".$_SESSION['email']."'
AND registrations.year='".$config['FAIRYEAR']."'");
- if(mysql_num_rows($q))
- $r=mysql_fetch_object($q);
+ $q->execute();
+ if($q->rowCount())
+ $r=$q->fetch(PDO::FETCH_OBJ);
else {
//no match from registrations, so lets see if it matches from the students table
- $q=mysql_query("SELECT registrations.num FROM
+ $q=$pdo->prepare("SELECT registrations.num FROM
registrations,
students
WHERE
students.email='".$_SESSION['email']."'
AND students.registrations_id=registrations.id
AND registrations.year='".$config['FAIRYEAR']."'");
- $r=mysql_fetch_object($q);
+ $q->execute();
+ $r=$q->fetch(PDO::FETCH_OBJ);
}
@@ -174,7 +182,7 @@ $q->execute();
if($q->rowCount()>0) {
- $r=mysql_fetch_object($q);
+ $r=$q->fetch(PDO::FETCH_OBJ);
// print_r($r);
echo i18n("Please enter your registration number in order to login");
echo " ";
@@ -227,8 +235,9 @@ $q->execute();
else if($config['participant_registration_type']=="schoolpassword") {
$showschoolpasswordform=true;
if($_POST['schoolpassword'] && $_POST['schoolid']) {
- $q=mysql_query("SELECT registration_password FROM schools WHERE id='".$_POST['schoolid']."' AND year='".$config['FAIRYEAR']."'");
- $r=mysql_fetch_object($q);
+ $q=$pdo->prepare("SELECT registration_password FROM schools WHERE id='".$_POST['schoolid']."' AND year='".$config['FAIRYEAR']."'");
+ $q->execute();
+ $r=$q->fetch(PDO::FETCH_OBJ);
if($_POST['schoolpassword']==$r->registration_password) {
$allownew=true;
@@ -250,10 +259,11 @@ $q->execute();
echo " ";
echo i18n("Email Address:")." ".$_SESSION['email']." ";
echo i18n("School: ");
- $q=mysql_query("SELECT id,school FROM schools WHERE year='".$config['FAIRYEAR']."' ORDER BY school");
+ $q=$pdo->prepare("SELECT id,school FROM schools WHERE year='".$config['FAIRYEAR']."' ORDER BY school");
+ $q->execute();
echo "";
echo "".i18n("Choose your school")." \n";
- while($r=mysql_fetch_object($q))
+ while($r=$q->fetch(PDO::FETCH_OBJ))
echo "id\">$r->school \n";
echo " ";
echo " ";
@@ -303,13 +313,14 @@ $q->execute();
//random number between
//100000 and 999999 (six digit integer)
$regnum=rand(100000,999999);
- $q=mysql_query("SELECT * FROM registrations WHERE num='$regnum' AND year=".$config['FAIRYEAR']);
- }while(mysql_num_rows($q)>0);
+ $q=$pdo->prepare("SELECT * FROM registrations WHERE num='$regnum' AND year=".$config['FAIRYEAR']);
+ $q->execute();
+ }while($q->rowCount()>0);
if(!$schoolidquery) $schoolidquery="null";
//actually insert it
- mysql_query("INSERT INTO registrations (num,email,start,status,schools_id,year) VALUES (".
+ $stmt = $pdo->prepare("INSERT INTO registrations (num,email,start,status,schools_id,year) VALUES (".
"'$regnum',".
"'".$_SESSION['email']."',".
"NOW(),".
@@ -317,6 +328,7 @@ $q->execute();
$schoolidquery.",".
$config['FAIRYEAR'].
")");
+ $stmt->execute();
email_send("new_participant",$_SESSION['email'],array(),array("REGNUM"=>$regnum,"EMAIL"=>$_SESSION['email']));
diff --git a/register_participants_emergencycontact.php b/register_participants_emergencycontact.php
index aaca19f..902b36e 100644
--- a/register_participants_emergencycontact.php
+++ b/register_participants_emergencycontact.php
@@ -38,22 +38,22 @@
exit;
}
- $q=mysql_query("SELECT registrations.id AS regid, students.id AS studentid, students.firstname FROM registrations,students ".
+ $q=$pdo->prepare("SELECT registrations.id AS regid, students.id AS studentid, students.firstname FROM registrations,students ".
"WHERE students.email='".$_SESSION['email']."' ".
"AND registrations.num='".$_SESSION['registration_number']."' ".
"AND registrations.id='".$_SESSION['registration_id']."' ".
"AND students.registrations_id=registrations.id ".
"AND registrations.year=".$config['FAIRYEAR']." ".
"AND students.year=".$config['FAIRYEAR']);
-echo mysql_error();
+echo $pdo->errorInfo();
- if(mysql_num_rows($q)==0)
+ if($q->rowCount()==0)
{
header("Location: register_participants.php");
exit;
}
- $authinfo=mysql_fetch_object($q);
+ $authinfo=$q->fetch(PDO::FETCH_OBJ);
//send the header
send_header("Participant Registration - Emergency Contact Information");
@@ -82,8 +82,9 @@ echo mysql_error();
//first, lets make sure this emergency contact really does belong to them
foreach($_POST['ids'] AS $id)
{
- $q=mysql_query("SELECT * FROM emergencycontact WHERE id='$id' AND registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
- if(mysql_num_rows($q)==1) {
+ $q=$pdo->prepare("SELECT * FROM emergencycontact WHERE id='$id' AND registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
+ $q->execute();
+ if($q->rowCount()==1) {
$e=stripslashes($_POST['email'][$id]);
if($_POST['relation'][$id]=="Parent" && $e && user_valid_email($e)) {
if($u=user_load_by_email($e)) {
@@ -106,17 +107,18 @@ echo mysql_error();
}
}
- mysql_query("UPDATE emergencycontact SET ".
- "firstname='".mysql_escape_string(stripslashes($_POST['firstname'][$id]))."', ".
- "lastname='".mysql_escape_string(stripslashes($_POST['lastname'][$id]))."', ".
- "relation='".mysql_escape_string(stripslashes($_POST['relation'][$id]))."', ".
- "phone1='".mysql_escape_string(stripslashes($_POST['phone1'][$id]))."', ".
- "phone2='".mysql_escape_string(stripslashes($_POST['phone2'][$id]))."', ".
- "phone3='".mysql_escape_string(stripslashes($_POST['phone3'][$id]))."', ".
- "phone4='".mysql_escape_string(stripslashes($_POST['phone4'][$id]))."', ".
- "email='".mysql_escape_string(stripslashes($_POST['email'][$id]))."' ".
+ $stmt = $pdo->prepare("UPDATE emergencycontact SET ".
+ "firstname='".stripslashes($_POST['firstname'][$id])."', ".
+ "lastname='".stripslashes($_POST['lastname'][$id])."', ".
+ "relation='".stripslashes($_POST['relation'][$id])."', ".
+ "phone1='".stripslashes($_POST['phone1'][$id])."', ".
+ "phone2='".stripslashes($_POST['phone2'][$id])."', ".
+ "phone3='".stripslashes($_POST['phone3'][$id])."', ".
+ "phone4='".stripslashes($_POST['phone4'][$id])."', ".
+ "email='".stripslashes($_POST['email'][$id])."' ".
"WHERE id='$id'");
- echo mysql_error();
+ $stmt->execute();
+ echo $pdo->errorInfo();
echo notice(i18n("Emergency contact information successfully updated"));
}
else
@@ -141,23 +143,25 @@ else if($newstatus=="complete")
}
-$sq=mysql_query("SELECT id,firstname,lastname FROM students WHERE registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
-$numstudents=mysql_num_rows($sq);
+$sq=$pdo->prepare("SELECT id,firstname,lastname FROM students WHERE registrations_id='".$_SESSION['registration_id']."' AND year='".$config['FAIRYEAR']."'");
+$sq->execute();
+$numstudents=$sq->rowCount();
echo "