Explorar o código

fuck up med array init position

Axel Nordh %!s(int64=6) %!d(string=hai) anos
pai
achega
be09fa895e
Modificáronse 2 ficheiros con 19 adicións e 4 borrados
  1. 17 2
      Assets/Scripts/Database/OnlineDatabase.cs
  2. 2 2
      dbFiles/OnlineGameInfo.php

+ 17 - 2
Assets/Scripts/Database/OnlineDatabase.cs

@@ -592,8 +592,8 @@ public class OnlineDatabase : MonoBehaviour {
         form.AddField("userName", playerName);
 
         string response = CallOnlineDatabaseWithResponse("OnlineGameInfo.php", form);
-        response = "{\"questionsList\" : [ " + response + " ]}";
-
+        response = "{\"questionsList\" : [" + response + "]}";
+        
         Questions ql = new Questions();
 
         JsonUtility.FromJsonOverwrite(response, ql);
@@ -611,6 +611,21 @@ public class OnlineDatabase : MonoBehaviour {
 
             questions.Add(qc);
         }
+
+        /*
+            
+                q.SetAnswerText(reader.GetInt32(2).ToString());
+                q.SetQuestionText(reader.GetString(1));
+                q.idString = reader.GetInt32(0).ToString();
+                Color32 questionCategoryColor = new Color32((byte)reader.GetInt32(7), (byte)reader.GetInt32(8), (byte)reader.GetInt32(9), (byte)reader.GetInt32(10));
+
+                q.SetQuestionCategoryColor(questionCategoryColor);
+
+                questions.Add(q);
+
+        
+        */
+        // TODO Fix online call to question
         return questions;
     }
 

+ 2 - 2
dbFiles/OnlineGameInfo.php

@@ -1,5 +1,4 @@
 <?php
-/* Games.php */ 
 	$hostname = 'localhost';
 	$username = 'narKampen';
 	$pass = 'narKampenPassword';
@@ -35,7 +34,7 @@
 		}
 	} else if ($callFunction === "PlayerQuestions") {
 		$userName = $conn->real_escape_string($_POST['userName']);
-		$sql = "SELECT question, answer, categoryId as category, r,g,b,a FROM questions 
+		$sql = "SELECT questions.id as id, question, answer, categoryId as category, r,g,b,a FROM questions 
 					INNER JOIN questionToCategory on questions.id = questionToCategory.questionId 
 					INNER JOIN category ON category.id = questionToCategory.categoryId 
 					WHERE questions.id IN 
@@ -44,6 +43,7 @@
 						gameId = $gameId AND playerName = '$userName') ORDER BY answer ASC";
 		$result = $conn->query($sql);
 		$returnArray = array();
+		$i = 0;
 		while ($data = $result->fetch_assoc()) {
 			foreach ($data as $key => $value) {
 				$returnArray[$i][$key] = $value;