From c87f23397f62469e5c6823632ee06c5fb0827c14 Mon Sep 17 00:00:00 2001 From: james Date: Thu, 3 Mar 2011 23:14:52 +0000 Subject: [PATCH] Add better debug messages to output --- api.php | 4 ++-- register_participants.inc.php | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/api.php b/api.php index 2a00b30..aa5e3e2 100644 --- a/api.php +++ b/api.php @@ -378,9 +378,9 @@ switch($request[0]) { $p = getProject($u['id']); if(is_array($p)) { $_SESSION['registration_id'] = $p['registrations_id']; - $_SESSION['registration_number'] = $p['num']; + $_SESSION['registration_number'] = $p['registration_number']; }else - $_SESSION['error'] = "project not found"; + $_SESSION['error'] = "project not found: $p"; } else{ diff --git a/register_participants.inc.php b/register_participants.inc.php index 258e61c..6120728 100644 --- a/register_participants.inc.php +++ b/register_participants.inc.php @@ -285,9 +285,8 @@ function saveProjectData($data,$registrations_id=null){ */ }else{ //first, lets make sure this project really does belong to them - $qstr="SELECT * FROM projects WHERE id='" . $data['project_id'] . "' AND registrations_id='" . $rid . "' AND conferences_id='" . $conference['id'] . "'"; - $q = mysql_query("SELECT * FROM projects WHERE id='" . $data['project_id'] . "' AND registrations_id='" . $rid . "' AND conferences_id='" . $conference['id'] . "'"); + $q = mysql_query($qstr); if(mysql_num_rows($q) == 1) { $summarywords = preg_split("/[\s,]+/", $data['summary']); $summarywordcount = count($summarywords); @@ -380,7 +379,7 @@ function saveProjectData($data,$registrations_id=null){ } } else { - $message = i18n("Invalid project to update"); + $message = i18n("Invalid project to update: %1",array($qstr)); } } return $message; @@ -518,8 +517,8 @@ function saveRegistrationData($d) { function getProject($userId){ global $conference; - $userid = intval($userId); - $result = mysql_fetch_assoc(mysql_query("SELECT registrations_id FROM users WHERE id = $userId")); + $userId = intval($userId); + $result = mysql_fetch_assoc(mysql_query("SELECT registrations_id FROM users WHERE id='$userId'")); if(!is_array($result)){ return "register_participants.inc.php::getProject -> User not found"; } @@ -541,9 +540,11 @@ function getProject($userId){ )); $q = mysql_query("SELECT $fields FROM projects JOIN registrations ON registrations.id = projects.registrations_id - WHERE projects.registrations_id='$regId' AND projects.conferences_id='".$conference['id']."' LIMIT 1"); + WHERE projects.registrations_id='$regId' + AND projects.conferences_id='".$conference['id']."' + LIMIT 1"); if(mysql_error()) { - $returnval = "register_participants.inc.php::getProject -> " . $returnval; + return "register_participants.inc.php::getProject -> " . $mysql_error(); }else{ $returnval = mysql_fetch_assoc($q); }