Sending and Receiving data using your own SQL Server - PHP file and TestProject included

145791016

Comments

  • ccdigitalccdigital Member, PRO Posts: 6
    edited August 2014

    Hi!

    Awesome work!
    I could make it work with a remote URL testing in my gamesalad, the json.txt file is generated in the server, but it's not inserting anything in the db. What I found is on the condition:

    while ($i < $arrlength ) [line 68]

    $arrlength is 0, so the loop never happens.

    This is the json file:
    {\"Properties\":[],\"Name\":\"\",\"Children\":[{\"Properties\":[{\"Name\":\"rowCount\",\"Value\":3},{\"Name\":\"columnCount\",\"Value\":3},{\"Name\":\"0-1-name\",\"Value\":\"playerID\"},{\"Name\":\"0-1-type\",\"Value\":1},{\"Name\":\"0-2-name\",\"Value\":\"playerName\"},{\"Name\":\"0-2-type\",\"Value\":1},{\"Name\":\"0-3-name\",\"Value\":\"playerStats\"},{\"Name\":\"0-3-type\",\"Value\":2}],\"Name\":\"id911451_headers\",\"Children\":[]},{\"Properties\":[{\"Name\":\"1\",\"Value\":\"|id1|Jonathan|123|\"},{\"Name\":\"2\",\"Value\":\"|id2|William|600|\"},{\"Name\":\"3\",\"Value\":\"|id3|Axl|467|\"}],\"Name\":\"id911451\",\"Children\":[]}]}

    It seems to be okay, but anyway arrlength is empty. Any ideas?

    My last question is: will it work in the GS arcade? Until now, I haven't succeeded there :( Do you know why?

    Thanks a lot in advance!

  • cannixcannix Member Posts: 36

    hi, thank you for teaching us how to use PHP & SQL server

    I believe 90% of people do not know php, do not understand JSON,

    We can see that we have to change PHP / To change the JSON / need to change GameSalad Table, we are very afraid,

    We spent a lot of time to learn your instructions and tutorials, but 90 percent of the people are all failed, but also have a lot of problems.

    Everyone saw to change PHP, JSON to change to change .... My God, back to the dinosaur era!

    We hope you can help,

    1. make a correct, no need to modify table of * .gameproj
    2. make a correct, no need to modify the php
    3. make a correct a SQL table, A full description of the setting procedure with pictures
    4. All other settings step instructions with pictures
    5. Give us a zap file, then unzipped, copied to there
    6. Under all of us can not modify, learn your tutorial

    Here, heartfelt thank you, thank you!

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    How can you say 90% fail did you pole everyone. These things take work and study and require time to learn. Study and dig into it and learn PHP sometimes you need to dig in yourself the forums can't do everything for you. By applying yourself you can become a value to the forum and help others in return.

  • AdnanHAdnanH Member Posts: 77

    it says downloading mamp can harm my computer?:/ did anyone else get this warning or is it just me?:S

  • primerprimer Member, PRO Posts: 3

    Hi to all, nice progress indeed, I was wondering will network send table to url work with curl call to rest auth api with GS table as a param ?

    My first thought is that the json send from GS is containing more that just the param for the curl which is single name in this case, so my question is, is it possible to make POST request to the CURL from the api and make know to GS was it Success or no ?

    thank you in advance

  • colandercolander Member Posts: 1,610

    @primer said:
    Hi to all, nice progress indeed, I was wondering will network send table to url work with curl call to rest auth api with GS table as a param ?

    My first thought is that the json send from GS is containing more that just the param for the curl which is single name in this case, so my question is, is it possible to make POST request to the CURL from the api and make know to GS was it Success or no ?

    thank you in advance

    Best to direct this to @stevej from GS he will be able to give you the correct answer.

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408

    I'm bumping this for new users, and to post that I spent yesterday afternoon setting this up from scratch for my new game along with my UID Generation process (http://forums.gamesalad.com/discussion/66786/generating-a-unique-id-for-asyc-metrics-whatever).

    works great :)

    It's coded to work with MAMP, and I'm happy to say it works with the latest version without doing anything. I'm going to be migrating this to a real server in the next week or so, either using Amazon EC2 or just my own web host, so if I have to make any changes I'll post here. I'll probably take the time to update it to MySQLi as MySQL is getting depreciated in PHP.

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    edited November 2014

    This is still by far the most useful (and my personal favorite) forum post ever... (to me anyway)..

    This got me to sign back up to being Pro back in the Spring as I'd started hanging back whilst awaiting some multiplayer support... I then worked through your setup, taught myself some basic MySQL programming and then a lot of server security stuff and got my games multiplayer working via a live server.

    I then got my head around PDO (I went with PDO insitead of MySQLi to replace the old MySQL as it actually seemed better and easier to transition over to...)...

    Finally it all got shelved for various reasons.. mainly I lost motivation after taking a break.. damn motivation always wins eventually).

    Then I went on to learn some pretty decent C# for something else... and now onto C++ and tinkering making some demos for the Oculus Rift...

    Actually find myself programming all the time now... I never thought I'd be doing that...

    Thanks again... I can't wait to see what you've been working on... (please send me a message when it goes live incase I miss it).

    I will be back soon (ish) to finish off the game that got put on the shelf for a few months.

    Here's the thread on where I got to if anyone is interested. Link

    Cheers again Mr Mulcahy...

    Stormy.

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408

    @StormyStudio‌

    thanks! i appreciate it a lot. I was amazed where you took this for your custom multiplayer implementation with facebook and everything, and your a* pathfinding was another big step forward. We need more people who innovate to really push the boundaries of GS!

    The only reason I got back into this now was the gamejam. I had been poking along with my game since april, and after creating a game for the GS gamejam I decided to flesh it out a bit and release it for iOS. I wanted to track how many people are opening the game, how many levels they are playing and how long to beat each level. It's take about 2 days, but I've got it all coded.

    I'm dying to get a oculus dev kit, but I think I am waiting for DK3 at this point. I've heard good things about the resolution improvements with it, and I really don't have any time right now for it to be anything more than a toy. I've got a whole unity class to get through before I'll be tackling that. :)

    if you ever release anything on the oculus let me know

  • outlandishPIXELoutlandishPIXEL Member Posts: 43

    I've yet to experiment with this but I have a project waiting in the wings. I'm looking forward to trying out some of this!

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408

    and just like my back end work is done. This is the basic process:

    1. User downloads and opens the app
    2. On the loading scene a UID is generated and saved to a table (http://forums.gamesalad.com/discussion/66786/generating-a-unique-id-for-asyc-metrics-whatever).
    3. The game sends out the UID, screen width/height and a timestamp.
    4. At the end of every 'level' the game sends the overall progress, and how many attempts it took to beat the current level. This entry is updated at the end of every level.

    From my end I can see how many people have downloaded the game, how often people are coming back to the game. how many levels people play in the game, how many attempts it takes to beat each level.

    Using this I'll be able to figure out if a certain level is too hard, how many levels people play until they quit, the screen resolution they are playing on, and based on that tell what iOS device they are using.

    This is really my trial run using all of this. My next 'real' game is going to make heavy heavy use of this. I plan on having a dedicated website with a huge infographic representing all the different outcomes.

  • scottharrrules43scottharrrules43 Tulsa, OklahomaMember, PRO Posts: 694
    edited November 2014

    how would one change the code around to make it compatible with a web host? I am using www.000webhost.com

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408

    @scottharrrules43 said:
    how would one change the code around to make it compatible with a web host? I am using www.000webhost.com

    you need to contact your webs host to see how their php and mysql is configured, but something like this should be pretty universal:

        // connect to SQL
        $servername = "localhost";
        $username = "username";
        $password = "password";
        $link = @mysql_connect($servername, $username, $password);
    
        // database connection strings. change these to your DB and Table names.
        $dbName = "cracked_buildingjumper";
        $tableName = "stats";
    
        if (!$link) {
            //exit('Error: Could not connect to MySQL server!');
            echo mysql_errno($link) . ": " . mysql_error($link). "\n";
    
        }
    
        // connect to the table
        mysql_select_db($dbName)or die("cannot select DB");
    
  • scottharrrules43scottharrrules43 Tulsa, OklahomaMember, PRO Posts: 694
    edited November 2014

    how do you make the link for your database with your own server? (I'm a noob at this stuff)

  • scottharrrules43scottharrrules43 Tulsa, OklahomaMember, PRO Posts: 694
    edited November 2014

    Ok ingnore thing above, I have a problem on my database I am gitting some errors. Can you help me?

    Edit: not on the password part I accendently put the wrong password am still getting line 16 bug


  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408

    @scottharrrules43 said:
    Ok ingnore thing above, I have a problem on my database I am gitting some errors. Can you help me?

    Edit: not on the password part I accendently put the wrong password am still getting line 16 bug


    What does your $link look like? I done see it listed there. Make sure caseing is correct. It's case sensitive

  • scottharrrules43scottharrrules43 Tulsa, OklahomaMember, PRO Posts: 694

  • scottharrrules43scottharrrules43 Tulsa, OklahomaMember, PRO Posts: 694

    Yes, 000webhosting.com

  • scottharrrules43scottharrrules43 Tulsa, OklahomaMember, PRO Posts: 694

    Going to bed good night

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408

    @scottharrrules43 said:
    Yes, 000webhosting.com

    Contact them for the right connection string, it doesn't like local host. Might be something special.

  • scottharrrules43scottharrrules43 Tulsa, OklahomaMember, PRO Posts: 694

    Ok thanks

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408

    @scottharrrules43 said:
    Ok thanks

    Here you go, from their website

    What is MySQL hostname?
    You have go to our members' area, enter the control panel and click on the 'MySQL' icon. Your MySQL hostname will be listed there.

    Important! Never use 'localhost' as your MySQL hostname here or you will get access denied errors!

  • scottharrrules43scottharrrules43 Tulsa, OklahomaMember, PRO Posts: 694

    Oh wow, I need to read more. Thanks for all your help let you know tommrow how it works.

  • scottharrrules43scottharrrules43 Tulsa, OklahomaMember, PRO Posts: 694

    I got an error on line 122.
    But the Json looks good :smile:

  • scottharrrules43scottharrrules43 Tulsa, OklahomaMember, PRO Posts: 694
    edited November 2014

    On sending my callback is changes to one but doesn't work. And receiving doesn't work at all.

    edit: it makes a json.text on my website when it is sends stuff from gamesalad.

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    edited November 2014

    @scottharrrules43 said:
    On sending my callback is changes to one but doesn't work. And receiving doesn't work at all.

    edit: it makes a json.text on my website when it is sends stuff from gamesalad.

    I'm guessing the JSON you are constructing to send back is incorrect, that's the most typical cause.

    first thing to do is take the existing project and php code and get that to run on your server. once that is working, edit it to suit your needs.

  • scottharrrules43scottharrrules43 Tulsa, OklahomaMember, PRO Posts: 694

    What about the line 122 thing?

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
  • scottharrrules43scottharrrules43 Tulsa, OklahomaMember, PRO Posts: 694
    edited November 2014

    tried your thing you made and the receive worked but the send did not work.
    Any ideas?

Sign In or Register to comment.