farflamex's Recent Forum Activity

  • Years of BASIC programming have made this really confusing. It's all working fine, the PHP part at least, but I'm trying to do things BASIC ways and presumably it just doesn't work that way. For example, I'm trying to do tests on the new $output values, but it's kinda ignoring me... e.g

    if ($output[1] = 2) {

    $query = $db->prepare("UPDATE Players SET PositionRT = :NewPos WHERE ID = :ID");

    }

    if ($output[1] = 3) {

    $query = $db->prepare("UPDATE Players SET PositionYT = :NewPos WHERE ID = :ID");

    }

    This ALWAYS executes the 2nd statement, even if $output[1] doesn't equal 3

  • Ah right, good point. There's no way to avoid this when using a C2 array right? For example you can't actually set a C2 array to 3,0,0 so I guess this is the only way?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ok cool got it, thanks. What is the nested foreach loop actually doing? Presumably parsing the array or something? This is where I was stuck, because I just assumed that after...

    $c2ArrayData = $jsonArray['data'];

    (actually I didn't know about the 'data' string either, so that wasn't helping). But anyway, I just assumed that after that, I could do a

    echo $c2ArrayData[0]; or maybe after $output = array(); I would be able to get $output[0]. It seems surprisingly complex but at least it works now. I assume I can just copy this code into my future snippets with any little changes needed.

  • Ah thanks, this is what I was looking for. I should point out that the output that I printed above was actually typed in so I must've made a typo - I was just dumping it to screen in a C2 text object and typed it out. It looks like I'm missing some steps in constructing my array. It's not quite working, I start with..

    $JsonC2ArrayString = file_get_contents("php://input");

    Which, as far as I can see, gives me exactly the same as the array you've typed above. Hmm, anyway cheers, I can see I've missed a few steps that are important so I should be able to fathom it from here

  • Hmm, looking through the various other JSON to PHP searches on the C2 forum, I don't seem to be alone in struggling with this. Not quite sure why, but after retrieving my JSON data in PHP, none of the methods from tutorials etc seem to give me a true PHP array. Probably doing something wrong. What I get at the PHP end is .... "{\"c2array\":true,\"size\":[3,1,1],\"data\":[[[60]]],[[1]],[[25]]]}".

    I assume that's correct, but when I use the various methods to break it down into a PHP array, I never seem able to access the individual elements. To be honest, I'm probably just doing it wrong, so I'll come back to it later. If anybody knows a simple way in PHP to retrieve a C2 JSON encoded array and then output/access the elements (e.g Array[0], Array[1]) etc, please let me know.

    In the meantime, my manual method was working fine and seems simpler to me, so I'll come back to this later

  • Cheers. I've got it working fine. The PHP forums are telling me it's best to use JSON so I'm working on that now. For my test I was just sending 3 ints, separated by pipes, e.g 60|5|1 , then splitting it with 'Explode' in my PHP script. Works absolutely fine and is adequate for my needs but maybe JSON is better for some reason? I'm not quite sure why, because to send it as JSON, I need to put my 3 numbers into a temporary array, send the Array.AsJSON, then do...

    $postdata = file_get_contents("php://input");

    $postdata = json_encode($postdata);

    Right now, I'm not sure how to make that into an array and access the values, but I'm sure it's pretty simple. Ploughing through tutorials and manuals and learning as I go.

    In fairness, it's pretty easy and tidy this way too. It just means I need to have a temporary array in C2, alter it's size, put the data into an array and send the array, as opposed to just creating and sending a string. While my method seems easier and I understand it more fully, maybe I should put the effort into learning the JSON way as it's more standard?

  • I get the basics. I have a php script which will update my database and the file is on my server. I know how to use AJAX to request the file and how to retrieve data, but I'm not quite sure how to send data for updates. Does my data need to be embedded in the url and retrieved with 'isset'? Is there another way, or does it always get embedded with the url this way? What would happen if for example I needed to send 50 pieces of data at once, would I just create a very long url and extract them individually with php?

  • k thanks.

  • I remember reading a few months ago that the arcade was going to be updated, to allow any screen size and to allow plug-ins. Has this happened yet and/or is it still in the pipeline?

  • Oh wow, I've been using 'tokenat' for years and always assuming the seperator was the token. Oddly, it doesn't matter if you get it wrong when using tokenat (if you assume tokenat 0 is the first seperator, you still get the first word anyway), but it does when you're using tokencount. Strangely, I was getting different results when using my AJAX.Lastdata string and an identical manual string, but it must've been because I was doing something slightly wrong.

    Anyway, it's working fine now, thanks for putting that straight

  • I'm new to AJAX/PHP so it might be something simple. I'm retrieving a simple string from a webpage, which is just '1|2|3|4'. Four numbers seperated by the pipe symbol. It arrives fine but when I come to parse it, tokencount tells me that it sees 4 '|' symbols when clearly there are 3.

    To check it's not an error in my program, I typed in the string directly into a variable and it parse that instead. In that case, it gives the correct answer of 3, so I don't think it's anything to do with my commands.

    Is this something strange about AJAX/PHP or have I done something wrong?

  • I like C2 and am now very comfortable with it. I need to redesign my business, which is a Soccer management game, currently played by email. It's in desperate need of an overhaul so I'm considering my options. I'd like to use C2, but here are some considerations.

    Screen design : Will require lots of text, the odd listbox and lots of different screens. My immediate thought is that C2 isn't really designed for that sort of game, but I've already designed a couple of the screens and I'm actually quite happy with it. It's all doable and it allows better graphics effects than languages such as VB. I sorta like being in control of my own clicks and events. So this part I'm happy with, even though it would be easier in something like VB.

    Language : I only really know various BASICS, such as C2, VB and Xojo (similar to VB). I HATE VB because it just seems impossible to deploy anything. Xojo requires a yearly license update which I don't want to pay. C2 is easier to deploy, free (I've already got a licence) and constantly updated (and has better forums).

    Server : Maybe the sticking point. I need my customers to log in to my server (I have a host already for my game), download the information for their teams, then transmit the data back to the server (this would be instead of the current email situation). I know how to do this using PHP and MySql, but only in Xojo. I'm really not sure if I could do this in C2. There would be quite a few MySql queries required and from what I've seen in tutorials/comments, it all looks a bit long-winded in C2. Has anyone done any larger projects with lots of MqSql/PHP/Ajax stuff?

farflamex's avatar

farflamex

Member since 7 Oct, 2012

Twitter
farflamex has 15 followers

Trophy Case

  • 12-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • x2
    Popular Game One of your games has over 1,000 players
  • Famous Game One of your games has over 10,000 players
  • RTFM Read the fabulous manual
  • Email Verified

Progress

18/44
How to earn trophies