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

1356716

Comments

  • RiffelRiffel Member Posts: 1,272
    @riffell
    check the logs under applications\MAMP\logs and see if there is anything there

    also check to the URL attributes in the game match the URL
    I find 3 files under applications\MAMP\logs
    apache_error.log
    mysql_error_log.err
    php_error.log


    URL game attributes
    http://localhost:8888/MAMP/asyncTest.php
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    Where do I find the template PHP to copy for step 5?

    Step 5: Configure PHP
    We are going to be copying the template PHP file into /Applications/MAMP/bin/mamp/. I have it called asyncTest.php, but you can call it anything you want, even index.php.

    Thanks
    Keep reading. It's a link towards the bottom
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    Any more luck Riffel.

    Happy to try and help if I can.
  • RiffelRiffel Member Posts: 1,272
    What's in the apache error log and pho log?
    apache error log

    [Mon Jan 27 14:21:58 2014] [notice] Digest: generating secret for digest authentication ...
    [Mon Jan 27 14:21:58 2014] [notice] Digest: done
    [Mon Jan 27 14:21:58 2014] [notice] Apache/2.2.25 (Unix) mod_ssl/2.2.25 OpenSSL/0.9.8y DAV/2 PHP/5.5.3 configured -- resuming normal operations
    [Mon Jan 27 15:58:52 2014] [error] [client ::1] script '/Applications/MAMP/bin/mamp/asynTest.php' not found or unable to stat
    [Tue Jan 28 13:33:04 2014] [error] [client ::1] File does not exist: /Applications/MAMP/bin/mamp/logs
    [Tue Jan 28 18:22:21 2014] [notice] caught SIGTERM, shutting down
    [Wed Jan 29 14:56:55 2014] [notice] Digest: generating secret for digest authentication ...
    [Wed Jan 29 14:56:55 2014] [notice] Digest: done
    [Wed Jan 29 14:56:55 2014] [notice] Apache/2.2.25 (Unix) mod_ssl/2.2.25 OpenSSL/0.9.8y DAV/2 PHP/5.5.3 configured -- resuming normal operations



    php error log

    [29-Jan-2014 18:46:05 Europe/Berlin] PHP Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /Applications/MAMP/bin/mamp/asyncTest.php on line 102
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    edited January 2014
    you've got a c missing on line 5 of your apache error code… but it's a few days old so may not be the answer...


    [Mon Jan 27 15:58:52 2014] [error] [client ::1] script '/Applications/MAMP/bin/mamp/asynTest.php' not found


    should be asyncTest not asynTest

    So a typo on the file or one of the references to it…

    Error code is couple of days old… :-/
  • EireStudiosEireStudios Member Posts: 451
    @jonmulcahy Is there anyway to overwrite a MySQL table value? i.e if I SendTable I would like it to overwrite the previous table value instead of creating a new row.
    yes, there are a few ways you could do it. you could drop and recreate the table, or update the table based on a unique key for each row. you'll want to google mysql commands and take a look, i have not implemented anything like that yet.
    Thanks Jon, I'll look into this a bit more tomorrow, I need to be able to be able to access a value and I can't pinpoint it in TableCellValue when the TableCell is always changing when I use the GetTable behaviour. There is probably an easy way around my problem but my head is soooo fried right now @-)
  • App_MakerApp_Maker Member, PRO Posts: 64
    I got the send and receive features working. I was wondering if there is a way we can check to see if a username is taken and if it is to force the person to select a new one to continue and once they select one thats not taken it will then save the information on the server.
  • EireStudiosEireStudios Member Posts: 451
    I got the send and receive features working. I was wondering if there is a way we can check to see if a username is taken and if it is to force the person to select a new one to continue and once they select one thats not taken it will then save the information on the server.
    I'm also going to implement something like this, I'm going to use @tatiang table search to see if the username has been entered, and if the table search finds it has it will prompt to enter another username, you can find the table search project file here http://forums.gamesalad.com/discussion/51765/faster-looping-and-table-searching
    It should be fairly easy to setup :)
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    edited January 2014
    HOLY ****

    Successfully able to bring my Facebook full friends list with id's into GameSalad.

    Just in time to go to the pub for a quiz...
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    edited January 2014
    @app_maker, @elirestudios

    I was thinking about this the other day, how to deal with enforcing a unique username for everyone and I came up with this. I don't know if it will work in practice, but it might

    let the users pick any username they want. store this in the username field.
    in another field take a copy of the username and append the exact date and time the user opened the app as a string of numbers. the odds of someone picking the exact same name and opening the app at the exact same millisecond is would be astronomically rare. Use this value as the primary key.

    that should work (in theory)
  • App_MakerApp_Maker Member, PRO Posts: 64
    I got the send and receive features working. I was wondering if there is a way we can check to see if a username is taken and if it is to force the person to select a new one to continue and once they select one thats not taken it will then save the information on the server.
    I'm also going to implement something like this, I'm going to use @tatiang table search to see if the username has been entered, and if the table search finds it has it will prompt to enter another username, you can find the table search project file here http://forums.gamesalad.com/discussion/51765/faster-looping-and-table-searching
    It should be fairly easy to setup :)
    Sounds good. I'll look into incorporating it in. Just starting to wonder what limitations there will be when it comes to the amount of users we can have. What if are game becomes popular and we have 1 million players, 5 million or even more players. Can gamesalad handle this? I remember having a table with 50000 rows of information and loading the game was really slow. It would suck to spend months making a app only to not have it work because we have to many people playing.
  • EireStudiosEireStudios Member Posts: 451
    @jonmulcahy good idea Jon, I'm going to try to create a working login system soon
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    I can't wait to get time to get into all this! But I'm going to focus on building a battleship type game demo for multiplayer just to see how best to code it in relation to the new tables and where to store what data. Need to stay focused or I'll be lost in a rabbit hole...lol
  • App_MakerApp_Maker Member, PRO Posts: 64
    So I did a little test getting the 3 different columns of information from the server for playerID, playerName, and playerStats. Well here's the issue when I press the GET button in my project so I can receive the updated table it takes WAY to long to receive it.

    For example,

    To receive 8,192 rows of information it took 6 seconds to load in the preview mode on my computer.
    16,384 rows took 20 seconds to load
    Then 32,768 rows didn't even load into my game after 5 minutes of waiting so I stop the timer.

    So it looks like were only able to make a multiplayer game for a few thousand people only. I sure hope I'm wrong but based on this it seems like loading would be to much of a issue to have anymore than a few thousand players only.
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    well you wouldn't need to store all the information for all the games locally i don't think. once GS adds the additional features to allow sending and getting a single row, we should be abel to have the server do most of the legwork.
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    edited January 2014
    well you wouldn't need to store all the information for all the games locally i don't think. once GS adds the additional features to allow sending and getting a single row, we should be abel to have the server do most of the legwork.
    The power, the unbelievable power Mwah ha ha ha ha ! … (yes I've had one too many baby chams)
  • EireStudiosEireStudios Member Posts: 451
    @jonmulcahy Hi Jon, quick question for you mate. Lets say I have 4 values saved in my table and I SendTable and those 4 values are sent to my server, is it normal for another 4 values to be placed under the original 4 values if I SendTable a second time? i.e it doesn't overwrite the original 4 just places the same 4 under the 4 original values. I just need to make sure its not an error in my code before I start messing with the .php file!
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    @jonmulcahy Hi Jon, quick question for you mate. Lets say I have 4 values saved in my table and I SendTable and those 4 values are sent to my server, is it normal for another 4 values to be placed under the original 4 values if I SendTable a second time? i.e it doesn't overwrite the original 4 just places the same 4 under the 4 original values. I just need to make sure its not an error in my code before I start messing with the .php file!
    it's normal, I'm doing a straight MySQl insert, it pays not attention to what is already in there. You want to look at doing an alter statement I think. I'm not too well versed in mySQL, but what you want to do should be pretty basic.
  • EireStudiosEireStudios Member Posts: 451
    edited January 2014
    @jonmulcahy Hi Jon, quick question for you mate. Lets say I have 4 values saved in my table and I SendTable and those 4 values are sent to my server, is it normal for another 4 values to be placed under the original 4 values if I SendTable a second time? i.e it doesn't overwrite the original 4 just places the same 4 under the 4 original values. I just need to make sure its not an error in my code before I start messing with the .php file!
    it's normal, I'm doing a straight MySQl insert, it pays not attention to what is already in there. You want to look at doing an alter statement I think. I'm not too well versed in mySQL, but what you want to do should be pretty basic.
    Thanks Jon, I think it's time I start learning some php and MySQL :)

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    @Riffel is it working now?
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    so I was doing some thinking on my way back from the gym, and even though this function is for sending table data, you can really do almost anything with it.

    1. use it to send an email with the contents of a table (server takes data, constructs and sends email)
    2. use it in a contest. ask users to input their email address when they open the app if, and when the game completes, upload the table with the email and send yourself and email
    3. custom metrics gathering, populate a table with device screen sizes and what not.
    4. keep track of how many people open your app. when the app is opened just call the behavior. it doesn't matter what it sends, just trigger some server side code to count the launch.
    5. sign up for a newsletter
  • EireStudiosEireStudios Member Posts: 451
    I figured out how to "Drop" the table and "Create" a new one, but when it creates a new table there is a new section under columns on my table called indexes and I think its stopping the GetTable behaviour from repopulating my in app Table, does anyone has any ideas on this?
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    @EireStudios
    check the apache/php logs under applications/MAMP/logs and see if it says anything
  • EireStudiosEireStudios Member Posts: 451
    @jonmulcahy its not showing any errors at all mate, I think its just something to do with the code in my app, I just can't seem to receive the table from my server no matter what I try, I love messing around with this php and mySQL stuff, but man does it fry your brain after two days :)
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    edited January 2014
    @EireStudios … are you trying to have the new data that goes to a table replace the previous data? if so I had this script working before.

    // CLEAR OUT THE TABLE, BEFORE ADDING TO IT (This removes any data currently residing in the table.... Put your table name where is says table_name.

    $clearResult = mysql_query('TRUNCATE TABLE table_name');

    if ($clearResult) {}
    else echo "Something went wrong: " . mysql_error();



    @jonmulcahy … loving the post gym ideas. So much seems possible. I saw some PHP code in my travels that looked to sort a CSV file into a MySQL database. So if the access is possible with GMAIL, YAHOO etc... should be ok to save their email contacts list… invite friends with it… or I guess based on your email ideas you could create a full email app and bring in the contacts.
  • EireStudiosEireStudios Member Posts: 451
    *Facepalm* wow thats a lot easier than what I was doing, I was dropping the table and rebuilding a new table every time I used SendTable @-) Now to test everything out, thanks Jon!
  • EireStudiosEireStudios Member Posts: 451
    I just can't seem to get the GetTable to work, I've tried everything I can possibly think of to get it working :( would anyone have a bit of free time to take a look at my project file and php script to make sure everything is ok, it would be nice to get a fresh set of eyes because I'm just about ready to pull my hair out 8-}
  • PhoticsPhotics Member Posts: 4,172
    edited January 2014
    Thanks Jon, I think it's time I start learning some php and MySQL :)
    Here's a link to a good website for that... http://www.w3schools.com
    The script is below, as an image. good luck!
    Is the code opensource? Perhaps this should be a github project? That would let the community work on it together.

    I was thinking of creating an Arcade module in Drupal, so that the games and players could be easily managed. But then, I started wondering about security. I don't want to be sending data back and forth unencrypted. I saw the news about apps leaking data... http://news.yahoo.com/report-spies-smartphone-apps-track-people-190434189.html ...and I didn't want my apps to do that.

    Plus, I still haven't figured out how to easily write data to Drupal. With views (kinda like GameSalad for web development), I can easily customize the display of data. Writing to the database, that's something else. Custom module development is something that I've struggled with.

    So while GameSalad has turned a corner, and finally let the community create something truly customizable, it still feels limited. Plus, I'm still waiting for the pesky metrics gathering to go away.

    @jonmulcahy This is very impressive thread! I wasn't expecting to see this level of development in a GameSalad forum.
    FYI, the Playstogether requirement for the URL commands WILL go away. I will also be adding a new network option "my own server" (or words to that effect) which will only enable the URL commands.
    Is there an ETA on that? I've been reading about a lot of cool stuff for GameSalad, but the app is still stuck on 0.10.4.1... and then there's the annoying metrics gathering ...so I haven't renewed my Pro subscription.
  • EireStudiosEireStudios Member Posts: 451
    edited January 2014
    @Photics the Playstogether requirement has been removed for "my own server" communication and it's in the newest nightly, I honestly don't know when it will be in the next non nightly version.

    Thanks for the link too mate, I'm going through a few tutorials at the moment, very interesting stuff :)
Sign In or Register to comment.