Quellcode durchsuchen

Test questions php

Axel Nordh vor 3 Jahren
Ursprung
Commit
9db98693cf
2 geänderte Dateien mit 30 neuen und 2 gelöschten Zeilen
  1. 2 2
      Assets/Scripts/Database/DatabaseController.cs
  2. 28 0
      ServerFiles/Questions.php

+ 2 - 2
Assets/Scripts/Database/DatabaseController.cs

@@ -7,8 +7,8 @@ public class DatabaseController : MonoBehaviour
 {
 
     private string secretKey = "TheNarKampenSecretKey";
-    public string questionURL = "http://nordh.xyz/narKampen/Questions.php?";
-    public string categoriesURL = "http://nordh.xyz/narKampen/Categories.php?";
+    public string questionURL = "http://nordh.xyz:8088/narKampen/Questions.php?";
+    public string categoriesURL = "http://nordh.xyz:8088/narKampen/Categories.php?";
 
     public Text statusText;
 

+ 28 - 0
ServerFiles/Questions.php

@@ -1 +1,29 @@
 <?php
+$HOST = 'nordh.xyz';
+$USERNAME = 'narKampen';
+$PASSWORD = '9Bq.6[AcTc2ADwN-';
+$DATABASE = 'narKampen';
+$PORT = '3306';
+
+$secretKey = 'TheNarKampenSecretKey';
+
+try {
+    $dbh = new PDO(
+        'mysql:host=' . $HOST . ';dbname=' . $DATABASE,
+        $USERNAME,
+        $PASSWORD
+    );
+} catch (PDOException $e) {
+    echo '<h1>An error har occured. </h1><pre>', $e->getMessage(), '</pre>';
+}
+
+$sth = $dbh->query('SELECT * FROM questions LIMIT 5');
+$sth->setFetchMode(PDO::FETCH_ASSOC);
+
+$result = $sth->fetchAll();
+
+if (count($result) > 0) {
+    foreach ($result as $r) {
+        echo $r['name'], "\t", $r['score'], "\n";
+    }
+}