Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 1 of 1

Thread: (+ Flash actually) What on earth is going on?

  1. #1
    44
    posts
    Registered User

    (+ Flash actually) What on earth is going on?

    Hi there.

    I am building a Flash game and I prepare to design a high score table for it. I've got a server running. Since this is my first time doing PHP and Flash together, I first designed a form so I just need to input values for different fields in order to create a record on the high score table (as seen in my attached .fla).

    The table on my database has the following structure:

    player_id: auto_increment (primary key)
    player_name: varchar(20)
    time_complete: int(4)
    resources: int(4)
    accuracy: int(3)
    combo: int(4)
    general: int(4)

    Quite straight forward actually.

    Next, I use the following php script to process the data when I press "submit" on my form.

    PHP Code:
    <?php
     
    //retrieving data from Flash
     
    $player $_POST['player_name'];
     
    $time $_POST['time_complete'];
     
    $resources $_POST['resources'];
     
    $accuracy $_POST['accuracy'];
     
    $combo $_POST['combo'];
     
    $general $_POST['general'];
     
    //end retrieving data from Flash
     //connect to database
     
    $link mysql_connect("(my server name)","(my user name)","(my password)");
     if (!
    $link) {
      print 
    "stat=Not connected.";
     } else {
      print 
    "stat=Connected.";
     }
     
    //end connect to database
     //sending scores to database
     
    mysql_select_db("xth_4326941_highscore",$link);
     
    $q_insert "INSERT INTO score (player_name,time_complete,resources,accuracy,combo,general) VALUES ('$player','$time','$resources','$accuracy','$combo','$general')";
     
    mysql_query($q_insert);
     
    /*$q_check = "SELECT * FROM score";
     $q_check_result = mysql_query($q_check);
     while($row = mysql_fetch_array($q_check_result)) {
      print "stat=$row['player_name']";
     }*/
     //end sending scores to database
     //close conection
     
    mysql_close($link);
     
    //end close connection
    ?>
    The connection is made successfully as displayed by the dynamic text box with the variable name "stat". The problem is that the data in the new record inserted that way became some rubbish.

    player_name: <TEXTFORMAT LEADING= //****
    time_complete: 0
    resources: 0
    accuracy: 0
    combo: 0
    general: 0

    **** it's really like that. "<TEXTFORMAT LEADING=". And nothing else.

    compared with what I have submitted:

    player_name: oi
    time_complete: 98
    resources: 98
    accuracy: 98
    combo: 98
    general: 98

    You'll all agree that it is quite rubbish.

    Anyone knows what on earth is going on? A problem with my table (created with phpmyadmin)? Or something wrong with my server? or as simple as some silly mistakes in my script?

    Thanks in advance.
    Attached Files Attached Files
    Last edited by wkt; October 27th, 2009 at 05:45 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012