diff --git a/admin/export_checkin.php b/admin/export_checkin.php
index 456b1d2f..ac549a6d 100644
--- a/admin/export_checkin.php
+++ b/admin/export_checkin.php
@@ -27,8 +27,9 @@
user_auth_required('committee', 'admin');
require("../lpdf.php");
-$catq=mysql_query("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' AND id='".$_GET['cat']."'");
-if($catr=mysql_fetch_object($catq))
+$catq=$pdo->prepare("SELECT * FROM projectcategories WHERE year='".$config['FAIRYEAR']."' AND id='".$_GET['cat']."'");
+$catq->execute();
+if($catr=$catq->fetch(PDO::FETCH_OBJ))
{
$pdf=new lpdf( i18n($config['fairname']),
@@ -38,7 +39,7 @@ if($catr=mysql_fetch_object($catq))
$pdf->newPage();
$pdf->setFontSize(11);
- $q=mysql_query("SELECT registrations.id AS reg_id,
+ $q=$pdo->prepare("SELECT registrations.id AS reg_id,
registrations.num AS reg_num,
registrations.status,
projects.title,
@@ -54,7 +55,8 @@ if($catr=mysql_fetch_object($catq))
ORDER BY
projects.title
");
- echo mysql_error();
+ $q->execute();
+ echo $pdo->errorInfo();
$table=array();
@@ -72,22 +74,24 @@ if($catr=mysql_fetch_object($catq))
$table['dataalign']=array("left","left","left","center");
}
- while($r=mysql_fetch_object($q))
+ while($r=$q->fetch(PDO::FETCH_OBJ))
{
- $divq=mysql_query("SELECT division,division_shortform FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' AND id='".$r->projectdivisions_id."'");
- $divr=mysql_fetch_object($divq);
+ $divq=$pdo->prepare("SELECT division,division_shortform FROM projectdivisions WHERE year='".$config['FAIRYEAR']."' AND id='".$r->projectdivisions_id."'");
+ $divq->execute();
+ $divr=$divq->fetch(PDO::FETCH_OBJ);
- $sq=mysql_query("SELECT students.firstname,
+ $sq=$pdo->prepare("SELECT students.firstname,
students.lastname
FROM
students
WHERE
students.registrations_id='$r->reg_id'
");
+ $sq->execute();
$students="";
$studnum=0;
- while($studentinfo=mysql_fetch_object($sq))
+ while($studentinfo=$sq->fetch(PDO::FETCH_OBJ))
{
if($studnum>0) $students.=", ";
$students.="$studentinfo->firstname $studentinfo->lastname";
diff --git a/admin/fair_stats.php b/admin/fair_stats.php
index de5c0da4..6fee0fc2 100644
--- a/admin/fair_stats.php
+++ b/admin/fair_stats.php
@@ -31,8 +31,9 @@
/* Hack so we can jump right to YSC stats */
if($_GET['abbrv'] == 'YSC') {
- $q = mysql_query("SELECT id FROM fairs WHERE abbrv='YSC'");
- $r = mysql_fetch_assoc($q);
+ $q = $pdo->prepare("SELECT id FROM fairs WHERE abbrv='YSC'");
+ $q->execute();
+ $r = $q->fetch(PDO::FETCH_ASSOC);
$_GET['id'] = $r['id'];
}
@@ -92,8 +93,9 @@
else $fairs_id = -1;
if($fairs_id != -1) {
- $q = mysql_query("SELECT * FROM fairs WHERE id='$fairs_id'");
- $fair = mysql_fetch_assoc($q);
+ $q = $pdo->prepare("SELECT * FROM fairs WHERE id='$fairs_id'");
+ $q->execute();
+ $fair = $q->fetch(PDO::FETCH_ASSOC);
}
$action = $_POST['action'];
@@ -215,24 +217,26 @@
/* And now, overwrite all the stuff we pulled down with stats we can compute */
//number of schools
- $q=mysql_query("SELECT COUNT(id) AS num FROM schools WHERE year='$year'");
- $r=mysql_fetch_object($q);
+ $q=$pdo->prepare("SELECT COUNT(id) AS num FROM schools WHERE year='$year'");
+ $q->execute();
+ $r=$q->fetch(PDO::FETCH_OBJ);
$stats['schools_total']=$r->num;
//number of schools participating
- $q=mysql_query("SELECT DISTINCT(students.schools_id) AS sid, schools.*
+ $q=$pdo->prepare("SELECT DISTINCT(students.schools_id) AS sid, schools.*
FROM students
LEFT JOIN registrations ON students.registrations_id=registrations.id
LEFT JOIN schools ON students.schools_id=schools.id
WHERE students.year='$year'
AND registrations.year='$year'
AND (registrations.status='complete' OR registrations.status='paymentpending')");
- $stats['schools_active']=mysql_num_rows($q);
+ $q->execute();
+ $stats['schools_active']=$q->rowCount();
$stats['schools_public'] = 0;
$stats['schools_private'] = 0;
$stats['schools_atrisk'] = 0;
$districts = array();
- while($si=mysql_fetch_assoc($q)) {
+ while($si=$q->fetch(PDO::FETCH_ASSOC)) {
if($si['designate'] == 'public')
$stats['schools_public']++;
if($si['designate'] == 'independent')
@@ -245,15 +249,16 @@
$stats['schools_districts'] = count($districts);
//numbers of students:
- $q=mysql_query("SELECT students.*,schools.*
+ $q=$pdo->error("SELECT students.*,schools.*
FROM students
LEFT JOIN registrations ON students.registrations_id=registrations.id
LEFT JOIN schools on students.schools_id=schools.id
WHERE students.year='$year'
AND registrations.year='$year'
AND (registrations.status='complete' OR registrations.status='paymentpending')");
- echo mysql_error();
- $stats['students_total'] = mysql_num_rows($q);
+$q->execute();
+ echo $pdo->errorInfo();
+ $stats['students_total'] = $q->rowCount();
$stats['students_public'] = 0;
$stats['students_private'] = 0;
$stats['students_atrisk'] = 0;
@@ -265,7 +270,7 @@
$stats["projects_$g"] = 0;
}
$unknown = array();
- while($s=mysql_fetch_assoc($q)) {
+ while($s=$q->fetch(PDO::FETCH_ASSOC)) {
if(!in_array($s['sex'], array('male','female')))
$unknown[$grademap[$s['grade']]]++;
else
@@ -287,7 +292,7 @@
}
//projects
- $q=mysql_query("SELECT MAX(students.grade) AS grade FROM students
+ $q=$pdo->prepare("SELECT MAX(students.grade) AS grade FROM students
LEFT JOIN registrations ON students.registrations_id=registrations.id
LEFT JOIN projects ON projects.registrations_id=registrations.id
WHERE students.year='$year'
@@ -295,28 +300,31 @@
AND projects.year='$year'
AND (registrations.status='complete' OR registrations.status='paymentpending')
GROUP BY projects.id");
- echo mysql_error();
- while($r=mysql_fetch_assoc($q)) {
+$q->execute();
+ echo $pdo->errorInfo();
+ while($r=$q->fetch(PDO::FETCH_ASSOC)) {
$stats["projects_{$grademap[$r['grade']]}"]++;
}
- $q=mysql_query("SELECT COUNT(id) AS num FROM users
+ $q=$pdo->prepare("SELECT COUNT(id) AS num FROM users
LEFT JOIN users_committee ON users_committee.users_id=users.id
WHERE types LIKE '%committee%'
AND year='$year'
AND users_committee.committee_active='yes'
AND deleted='no'");
- $r = mysql_fetch_object($q);
+$q->execute();
+ $r = $q->fetch(PDO::FETCH_OBJ);
$stats['committee_members'] = $r->num;
- $q=mysql_query("SELECT COUNT(id) AS num FROM users LEFT JOIN users_judge ON users_judge.users_id=users.id
+ $q=$pdo->prepare("SELECT COUNT(id) AS num FROM users LEFT JOIN users_judge ON users_judge.users_id=users.id
WHERE users.year='$year'
AND users.types LIKE '%judge%'
AND users.deleted='no'
AND users_judge.judge_complete='yes'
AND users_judge.judge_active='yes'");
- $r=mysql_fetch_object($q);
+$q->execute();
+ $r=$q->fetch(PDO::FETCH_OBJ);
$stats['judges'] = $r->num;
diff --git a/admin/fair_stats_select.php b/admin/fair_stats_select.php
index 3d9050a2..2f6d61ba 100644
--- a/admin/fair_stats_select.php
+++ b/admin/fair_stats_select.php
@@ -52,8 +52,9 @@
}
}
$s = join(',', $_POST['stats']);
- $q = mysql_query("UPDATE fairs SET gather_stats='$s' WHERE id='$id'");
- echo mysql_error();
+ $q = $pdo->prepare("UPDATE fairs SET gather_stats='$s' WHERE id='$id'");
+ $q->execute();
+ echo $pdo->errorInfo();
echo "UPDATE fairs SET gather_stats='$s' WHERE id='$id'";
happy_("Saved");
exit;
@@ -62,8 +63,9 @@
/* Load the user we're editting */
$u = user_load($_SESSION['embed_edit_id']);
/* Load the fair attached to the user */
- $q = mysql_query("SELECT * FROM fairs WHERE id={$u['fairs_id']}");
- $f = mysql_fetch_assoc($q);
+ $q = $pdo->prepare("SELECT * FROM fairs WHERE id={$u['fairs_id']}");
+ $q->execute();
+ $f = $q->fetch(PDO::FETCH_ASSOC);
?>
diff --git a/admin/fix_judges_autocomplete.php b/admin/fix_judges_autocomplete.php
index dec1036e..291aa6e2 100644
--- a/admin/fix_judges_autocomplete.php
+++ b/admin/fix_judges_autocomplete.php
@@ -5,18 +5,22 @@ require_once("../user.inc.php");
user_auth_required('committee', 'admin');
-$q = mysql_query("SELECT * FROM judges WHERE passwordexpiry IS NULL");
-while($i = mysql_fetch_object($q)) {
+$q = $pdo->prepare("SELECT * FROM judges WHERE passwordexpiry IS NULL");
+$q->execute();
+while($i = $q->fetch(PDO::FETCH_OBJ)) {
echo "Autocompleting Judge {$i->email} ";
$id = $i->id;
$p = generatePassword(12);
- mysql_query("UPDATE judges SET password='$p',complete='yes'");
- echo mysql_error();
- mysql_query("DELETE FROM judges_years WHERE judges_id='$id'");
- echo mysql_error();
- mysql_query("INSERT INTO judges_years (`judges_id`,`year`) VALUES ('$id','{$config['FAIRYEAR']}')");
- echo mysql_error();
+ $stmt = $pdo->prepare("UPDATE judges SET password='$p',complete='yes'");
+ $stmt->execute();
+ echo $pdo->errorInfo();
+ $stmt = $pdo->prepare("DELETE FROM judges_years WHERE judges_id='$id'");
+ $stmt->execute();
+ echo $pdo->errorInfo();
+ $stmt = $pdo->prepare("INSERT INTO judges_years (`judges_id`,`year`) VALUES ('$id','{$config['FAIRYEAR']}')");
+ $stmt->execute();
+ echo $pdo->errorInfo();
}
?>
diff --git a/admin/fundraising_campaigns.php b/admin/fundraising_campaigns.php
index 42fd00fb..bc3e9a01 100644
--- a/admin/fundraising_campaigns.php
+++ b/admin/fundraising_campaigns.php
@@ -34,8 +34,9 @@ switch($_GET['action']){
case "modify":
echo "
\n";
- $q=mysql_query("SELECT * FROM fundraising_campaigns WHERE fiscalyear='{$config['FISCALYEAR']}' ORDER BY name");
- while($r=mysql_fetch_object($q)) {
+ $q=$pdo->prepare("SELECT * FROM fundraising_campaigns WHERE fiscalyear='{$config['FISCALYEAR']}' ORDER BY name");
+ $q->execute();
+ while($r=$q->fetch(PDO::FETCH_OBJ)) {
echo "