rkatti's Recent Forum Activity

  • Checked every possible reason and it still isn't working. Really need some help with this.

  • I'm using the ajax post to url itself, not request. Still not able to figure this out. Any other reason it might not be working?

  • I'm trying to post a large string variable into a mysql server using php.The php file works fine when the variable isn't too large but due to the limitations of $_GET i need to use $_POST. Here is my php file:

    <?php
    
    $db = "";//Your database name
    $dbu = "";//Your database username
    $dbp = "";//Your database users' password
    $host = "localhost";//MySQL server - usually localhost
    
    $dblink = mysql_connect($host,$dbu,$dbp);
    $seldb = mysql_select_db($db);
    
    if(isset($_GET['arraydata'])){
    
         //Lightly sanitize the GET's to prevent SQL injections and possible XSS attacks
          $arraydata = strip_tags(mysql_real_escape_string($_GET['arraydata']));
         $sql = mysql_query("INSERT INTO `$db`.`scores` (`id`,`arraydata`) VALUES ('','$arraydata')");
         
         if($sql){
         
              //The query returned true - now do whatever you like here.
              echo 'Your score was saved. Congrats!';
              
         }else{
         
              //The query returned false - you might want to put some sort of error reporting here. Even logging the error to a text file is fine.
              echo 'There was a problem saving your score. Please try again later.';
              
         }
         
    }
    else{
         echo 'Your name or score wasnt passed in the request. Make sure you add ?name=NAME_HERE&score=1337 to the tags.';
    }
    
    mysql_close($dblink);//Close off the MySQL connection to save resources.
    ?>

    When I switch the $_GET with $_POST nothing is getting posted to the mysql server. Any ideas on how I go about doing this?

  • Paradox

    could you post an example of your php file cause it's not working when I enter it manually either. I'm guessing it has to be something to do with the mysql syntax in the php file.

  • cvp

    It didn't work. Is there any other reason it might not be passing?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • cvp

    dl.dropboxusercontent.com/u/88263565/record.capx is the capx file

    dl.dropboxusercontent.com/u/88263565/savescores.php is the php file we're using to pass it to mysql.

  • I have a global string variable whose output is something like:

    265|53|232|etc. etc.

    I need to pass this variable to a server using AJAX and PHP and store it in a MYSQL database. Text variables are getting stored in the server but this isn't. Any ideas why?

rkatti's avatar

rkatti

Member since 18 Nov, 2013

None one is following rkatti yet!

Trophy Case

  • 11-Year Club
  • Email Verified

Progress

12/44
How to earn trophies