Browse Source

Fixing SQL error

Julio Montoya 12 years ago
parent
commit
4357a16269
1 changed files with 8 additions and 6 deletions
  1. 8 6
      main/exercice/hotpotatoes.lib.php

+ 8 - 6
main/exercice/hotpotatoes.lib.php

@@ -76,12 +76,14 @@ function GetComment($path, $course_code = '') {
     global $dbTable;    
     $course_info = api_get_course_info($course_code);            
     $path = Database::escape_string($path);
-    $query = "SELECT comment FROM $dbTable WHERE c_id = {$course_info['real_id']} AND path='$path'";
-    $result = Database::query($query);
-    while ($row = Database::fetch_array($result)) {
-        return $row[0];
+    if (!empty($course_info) && !empty($path)) {
+        $query = "SELECT comment FROM $dbTable WHERE c_id = {$course_info['real_id']} AND path='$path'";
+        $result = Database::query($query);
+        while ($row = Database::fetch_array($result)) {
+            return $row[0];
+        }
     }
-    return '';
+    return null;
 }
 
 /**
@@ -97,7 +99,7 @@ function SetComment($path, $comment) {
     $course_id = api_get_course_int_id();
     $query = "UPDATE $dbTable SET comment='$comment' WHERE $course_id AND path='$path'";
     $result = Database::query($query);
-    return "$result";
+    return $result;
 }
 
 /**