-1
function sched_exists($cl_id, $teacher_id, $student_id) {
    $cl_id;
    $teacher_id;
    $student_id;
    return (mysql_result(mysql_query("SELECT COUNT(`sched_id`) FROM `sched` WHERE `class_id` = '$cl_id' AND `teacher_id` = '$teacher_id' AND `stduent_id` = '$student_id'"), 0) == 1) ? true : false; or die(mysql_error());
}

Can you tell me if my code is right? I get this error

Parse error: syntax error, unexpected 'or' (T_LOGICAL_OR) in C:\xampp\htdocs\GradingExpress\admin\core\functions\users.php on line 4"

tobias_k
  • 81,265
  • 12
  • 120
  • 179
  • **Danger**: You are using [an **obsolete** database API](http://stackoverflow.com/q/12859942/19068) and should use a [modern replacement](http://php.net/manual/en/mysqlinfo.api.choosing.php). You are probably **vulnerable to [SQL injection attacks](http://bobby-tables.com/)** that a modern API would make it easier to [defend](http://stackoverflow.com/questions/60174/best-way-to-prevent-sql-injection-in-php) yourself from. – Quentin Jan 19 '15 at 09:22
  • Dang! Please don't chain function calls like this, it makes your code non-human parseable... (nor machine parseable, apparently :) – RandomSeed Jan 19 '15 at 11:20
  • @RandomSeed so what do u suggest? – Albert Saludaga Jan 21 '15 at 13:51

1 Answers1

0

You have or die() after the semicolon which isn't allowed. You can remove that, mysql_error can't be there.

return (mysql_result(mysql_query("SELECT COUNT(`sched_id`) FROM `sched` WHERE `class_id` = '$cl_id' AND `teacher_id` = '$teacher_id' AND `stduent_id` = '$student_id'"),0)==1) ? true : false;
pavel
  • 26,538
  • 10
  • 45
  • 61