JSON is a standard lightweight data-interchange format which is quick and easy to parse and generate. JSON stands for Java Script Object Notation. In this tutorial you will learn how to encode and decode JSON data in PHP. What i wrote here just consists of general programming knowledge eg variables, arrays etc and then the php mysqli api.Īs i have said i have only just started learning this stuff so if anyone spots any mistakes or knows a better way to do things or any comments or suggestions on how i can improve the script then please let me know.Įcho(json_encode(array('status'=>"Connection failed: ". Here is my script i have commented it to help others if they need it Up untill last week i had never used php or json or varest before so all of this stuff was a massive headache for meĪfter days of frustration, reading documentation, code api’s, following every single php tutorial i could find, reading every varest thread i could find and non stop experimenting, i finally figured it out.įIRST problem was getting a Valid Json response to work with inside unreal. I think I need to put the results of the query into an array and then echo the arrayīut not sure how to then put each result into a field so that i can still use the field nodes in unreal as these seem to only take a single value? Im sure it is possible i just need a little help figuring out how. So please if anyone can help on how to do this i would be very happy.Īt the moment the work around i have is to have a separate PHP script for every single server and just query them one at a time, which is not too bad as the database is only little but obviously this would soon become a nightmare if i had loads of servers. Of course i would like to do this for all of my servers. If (serverName = Lobby & ServerStatus = offline) So here you can see the logic im trying to do is So does anyone know how i would solve this problem so that i can do logic like thisĠacd2357eada4b34b47f72bca6753cd5.png 1815×540 93 KB Mysqli_stmt_bind_result($stmt, $ServerName, $ServerStatus) Įcho json_encode(array('ServerName'=>$ServerName, 'ServerStatus'=>$ServerStatus)) īut it is not valid json and so wont work in unreal. $query = "SELECT ServerName, ServerStatus FROM statusCheck ORDER by ID" ![]() select All ServerNames & ServerStatus from the statusCheck database and sort them by ID order Now the problem is when i alter my query to try and return **ALL **the results from the database. Inside unreal i setup a test to see if it works like soĠacd2357eada4b34b47f72bca6753cd5.png 1815×540 92.7 KB So i know that in this case the lobby server is offline because i specifically selected the Lobby server in the query. Now this works perfectly, when i run the script i get the following json Mysqli_stmt_bind_result($stmt, $ServerStatus) Įcho json_encode(array('ServerStatus'=>$ServerStatus)) ![]() If ($stmt = mysqli_prepare($link,$query)) $query = "SELECT ServerStatus FROM statusCheck WHERE ServerName ='Lobby'" ![]() select Lobby Status from the statusCheck database so i wrote my php script like thisĮcho(json_encode(array('status'=>"Connection failed: ". So for this example i want to query the database and return the status of just 1 server (Lobby) and see if it is online or not. This is my database at the moment it is very basic for testing. So what i am trying to do is query my statusCheck database, which contains all the information stored about my servers and then send the result of this query back to unreal via json so that i can then use this data to drive my blueprint logic and then also use this data to populate a UMG widget that will show the clients all the server information K i deleted my other thread because i think i didn’t explain myself clearly and people were getting confused when they were trying to answer me. PROBLEM SOLVED SEE LAST POST IF YOU ARE INTERESTED IN THE ANSWER.
0 Comments
Leave a Reply. |