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

11012141516

Comments

  • J.PharaohJ.Pharaoh Member, PRO Posts: 32

    Hello, here is the google.drive. Pls take a look. Thx.

    https://drive.google.com/file/d/0BxlcIgIfedOraDVBQkE0WHUzQzQ/view?usp=sharing

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    edited March 2016

    @simbig said:
    Hello, here is the google.drive. Pls take a look. Thx.

    https://drive.google.com/file/d/0BxlcIgIfedOraDVBQkE0WHUzQzQ/view?usp=sharing

    converting it to an rtf file introduced a bunch of bad formatting characters

    I want you to remove the // from line 37, the one starting with $fullArray

    remove the /* from line 60 and */ from line 64

    when that is done, go to your MAMP directory and read through the json.txt, fullArray.txt and sqlErrors.txt to see if anything is wrong.

    json and sqlErrors should already exist on your server.

  • J.PharaohJ.Pharaoh Member, PRO Posts: 32

    Here is the asyncTest.php after corrected.

    https://drive.google.com/file/d/0BxlcIgIfedOrbWF6WUVsb192TEk/view?usp=sharing

    I run your game salad project. I still get -1 for both send and get.
    Would u help me to take look? Thx.

  • J.PharaohJ.Pharaoh Member, PRO Posts: 32

    This is what I get.

  • J.PharaohJ.Pharaoh Member, PRO Posts: 32

    One thing I am not sure is that the MAMP server:localhost:8889. But the URL we using in the game salad is 8888. Does this matter?

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408

    @simbig said:

    One thing I am not sure is that the MAMP server:localhost:8889. But the URL we using in the game salad is 8888. Does this matter?

    It does. Looking at your screenshots I don't see any logs, which means your not hitting the server. The wrong port number would donit

  • colandercolander Member Posts: 1,610

    @jonmulcahy said:

    @tatiang said:
    @Colander It's the opposite for me. I can Get from the server but not Send. I tried hard coding the Send URL both as a quoted expression and after removing the expression and pasting it in. I'll play around with it some more...

    ok, I'm back at a computer today. Are you still having trouble with this? I rewrote the get function to create a new log file called getErrors.txt and it will log every major piece of the function to it. Can you try running with it and see what you get?


    // start GET data...

    @jonmulcahy sorry I missed this, I bought a computer repair shop in mid December and have been flat out since. I did get it sorted but I can't remember what the issue was. Thanks for the response, I will get back to this project when time permits.

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408

    @colander said:

    @jonmulcahy said:

    @tatiang said:
    @Colander It's the opposite for me. I can Get from the server but not Send. I tried hard coding the Send URL both as a quoted expression and after removing the expression and pasting it in. I'll play around with it some more...

    ok, I'm back at a computer today. Are you still having trouble with this? I rewrote the get function to create a new log file called getErrors.txt and it will log every major piece of the function to it. Can you try running with it and see what you get?


    // start GET data...

    @jonmulcahy sorry I missed this, I bought a computer repair shop in mid December and have been flat out since. I did get it sorted but I can't remember what the issue was. Thanks for the response, I will get back to this project when time permits.

    Glad you got it sorted, good luck with the shop! Lemme know if you have any questions when you get back to it and I'll try to help

  • J.PharaohJ.Pharaoh Member, PRO Posts: 32
    edited March 2016

    @jonmulcahy said:

    It does. Looking at your screenshots I don't see any logs, which means your not hitting the server. The wrong port number would donit

    I change the send and get URL to localhost:8889/MAMP/asyncTest.php . However, nothing happen when I run the project and press the send or get button. Neither 1 or -1. I don't know what step I miss. :'(

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408

    If you browse to localhost:8889/MAMP/asyncTest.php what do you see? It should be a blank page.

    if you right click on and view source, what do you see?

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408

    The very first thing that happens when the app talks with the server is it creates a json.txt file that contains the table data. If you don't see this, then the app is not reaching the server. It would be in this folder:

    also, you are testing this all on the same machine right? That's the only way localhost would work. If you are running gamesalad on a seperate machine, you would need to change localhost to the actual IP address

  • J.PharaohJ.Pharaoh Member, PRO Posts: 32
    edited March 2016

    I got a blank page when I browse to localhost:8889/MAMP/asyncTest.php, but I can not get the right click to view source. Also I don't see any Json.txt file in the folder. I run the GS and the MAMP on the same machine. I just don't know why.
    I try the appformative network function. They work on my Mac.

    One more question. Does it matter with the Server connection collation ?

  • J.PharaohJ.Pharaoh Member, PRO Posts: 32

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408

    @simbig said:
    I got a blank page when I browse to localhost:8889/MAMP/asyncTest.php, but I can not get the right click to view source. Also I don't see any Json.txt file in the folder. I run the GS and the MAMP on the same machine. I just don't know why.
    I try the appformative network function. They work on my Mac.

    One more question. Does it matter with the Server connection collation ?

    Put a new line after the the <?php line at the top and type in

    Echo 'test';

    And browse there again. You should see test.

    Also post contents of applications/mamp/logs

  • J.PharaohJ.Pharaoh Member, PRO Posts: 32

    @jonmulcahy said:

    Put a new line after the the <?php line at the top and type in

    Echo 'test';

    And browse there again. You should see test.

    Also post contents of applications/mamp/logs

    I add the Echo 'test'; . Then the localhost: 8888 shows 'test', but the 8889 doesn't.

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408

    @simbig said:

    @jonmulcahy said:

    Put a new line after the the <?php line at the top and type in

    Echo 'test';

    And browse there again. You should see test.

    Also post contents of applications/mamp/logs

    I add the Echo 'test'; . Then the localhost: 8888 shows 'test', but the 8889 doesn't.


    Then you need to point the app to 8888

    After you do that try and load the site. After that attach those 3 log files to a post

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408

    @simbig
    This is over and over and over again in the Apache log

    `File does not exist: /Applications/MAMP/htdocs/mamp
    [Fri Mar 18 13:06:04 2016] [error] [client ::1] File does not exist: /Applications/MAMP/htdocs/mamp
    [Fri Mar 18 13:06:04 2016] [error] [client ::1] File does not exist: /Applications/MAMP/htdocs/mamp
    [Fri Mar 18 13:06:04 2016] [error] [client ::1] File does not exist: /Applications/MAMP/htdocs/mamp
    [19-Mar-2016 03:07:56 Europe/Berlin] PHP Fatal error:  Uncaught Error: Call to undefined function mysql_connect() in /Applications/MAMP/bin/mamp/asyncTest.php:15
    Stack trace:
    #0 {main}
      thrown in /Applications/MAMP/bin/mamp/asyncTest.php on line 15
    [19-Mar-2016 03:07:57 Europe/Berlin] PHP Warning:  Cannot modify header information - headers already sent by (output started at /Applications/MAMP/bin/mamp/asyncTest.php:2) in /Applications/MAMP/bin/mamp/php/functions.php on line 47
    

    And this is over and over in the PHP log

    `[19-Mar-2016 03:07:53 Europe/Berlin] PHP Fatal error:  Uncaught Error: Call to `undefined function mysql_connect() in `/Applications/MAMP/bin/mamp/asyncTest.php:15
    `Stack trace:
    `#0 {main}
     ` thrown in /Applications/MAMP/bin/mamp/asyncTest.php on line 15
    

    what version of PHP are you using? Make sure MAMP is configured to use 5.6.10, version 7.0.0 isn't tested and could be the problem

  • J.PharaohJ.Pharaoh Member, PRO Posts: 32
    edited March 2016

    Oh my God! Finally, I can send the table. Thank you very much after I stuck here for couple months. I couldn't believe the problem is in the php version. Now only the get function left. I will try by my self first. Once again, thank you for your patient. :)

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408

    @simbig said:
    Oh my God! Finally, I can send the table. Thank you very much after I stuck here for couple months. I couldn't believe the problem is in the php version. Now only the get function left. I will try by my self first. Once again, thank you for your patient. :)

    Good!
    One of these days I need to go through and update this for 7.0.0. Good summer project

  • J.PharaohJ.Pharaoh Member, PRO Posts: 32

    Hello is me again. I still can't run the "get" function properly. In your asyncTest.gameproj, it show show all the table value from the server, if the "get" function work. I don't know why the sendTable and the receiveTable value always be 0. Even the sendTable is working.

  • J.PharaohJ.Pharaoh Member, PRO Posts: 32
    edited March 2016

    Oh, finally I get it work. I add back the

    file_put_contents('updatedjson.txt',$returnedJson);

    after

    $returnedJson=$jsonHeadher.$jsonBody.$jsonFooter;

    It works great. I miss this post in the earlier day. Now got fixed. Thank you so much Jon and those who leave message here.

  • J.PharaohJ.Pharaoh Member, PRO Posts: 32

    One more question, I find the asyncTest.php has a line

    $jsonFooter='],"Name":"id911451","Children":[]}]}';

    The id911451 is the table file name in Gamesalad. Does this name have to match each other ?

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408

    @simbig said:
    One more question, I find the asyncTest.php has a line

    $jsonFooter='],"Name":"id911451","Children":[]}]}';

    The id911451 is the table file name in Gamesalad. Does this name have to match each other ?

    yes, the ID should match what your app is sending, by looking at the JSON.txt file when you do a send, you'll get your app's ID

  • J.PharaohJ.Pharaoh Member, PRO Posts: 32

    Now, it comes to the server part. I change the login name and password. I set the asyncTest.php into my server. I can send data to the server, but can not get. Don't know what's wrong.

  • J.PharaohJ.Pharaoh Member, PRO Posts: 32

    WOV, it works on my own server now. I need to remove the "Echo Test" from the beginning of the php file. Thanks guy.

  • granternxtgranternxt Member, PRO Posts: 4

    What does children, properties, and 1 mean in $arrlength = count($array['Children']['1']['Properties']);?

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    edited June 2016

    @granternxt said:
    What does children, properties, and 1 mean in $arrlength = count($array['Children']['1']['Properties']);?

    let me think, it's been awhile.

    Children and Properties are part of the original JSON format. I forget what the 1 is for, but it has to deal with the subarrays that are created.

  • Shenanigans StudioShenanigans Studio Member, PRO Posts: 73

    When I hit the Send and Get buttons I get a positive "1" callback attribute for both, however the table doesnt update when I hit get, and when I hit send the table doesnt show up in my SQL database. I get this error in phperror

    [29-Jun-2016 06:33:35 UTC] PHP Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\MAMP\bin\mamp\asyncTest.php on line 114

    heres my asynctest.php file

  • MantoManto Member Posts: 796

    @Shenanigans Studio said:
    When I hit the Send and Get buttons I get a positive "1" callback attribute for both, however the table doesnt update when I hit get, and when I hit send the table doesnt show up in my SQL database. I get this error in phperror

    [29-Jun-2016 06:33:35 UTC] PHP Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\MAMP\bin\mamp\asyncTest.php on line 114

    heres my asynctest.php file

    What is the value of your $tableName ? Does that table exist in the database?

    mysql_query returns False if the query fails so that would cause the error you get.

Sign In or Register to comment.