Ajax Problem!

0 favourites
  • 10 posts
  • Hi,

    I follow the tutorial the link below.

    scirra.com/tutorials/346/online-high-score-table-ajax-php-mysql

    i can save data to database.there is two problem then this point.First my data saves with integrated text like "name1|number1|name2|number2|name3...so is there any way clean previous data ? and if i get data with ajax how can i separate text before and after "|" charecter.

    I wait your help.

    Regards,

  • Help please :) ArcadEd

  • string1 = "name1|number1|name2|number2|name3"

    you can get:

    name1 by calling "tokenat(string1,0,"|")"

    name2 by calling "tokenat(string1,2,"|")"

    etc..

    tokenat explaination:

    scirra.com/manual/126/system-expressions

    To delete from the database, you have to create a new php script to send query to the database to delete what you want to delete as it is not included inside ArcadEd php files.

  • string1 = "name1|number1|name2|number2|name3"

    you can get:

    name1 by calling "tokenat(string1,0,"|")"

    name2 by calling "tokenat(string1,2,"|")"

    etc..

    tokenat explaination:

    https://www.scirra.com/manual/126/system-expressions

    To delete from the database, you have to create a new php script to send query to the database to delete what you want to delete as it is not included inside ArcadEd php files.

    Thansk so much i tried tokenat and it works thanks.bu i dont know how i delete database everry time? please help ArcadEd

    Ouote for help

  • While waiting for his reply. You can read up how to delete database entry at here:

    tutorialspoint.com/mysql/mysql-delete-query.htm

    You just have to know which query to send to mysql and you can tweak base on the php scripts arcadEd provided.

  • While waiting for his reply. You can read up how to delete database entry at here:

    http://www.tutorialspoint.com/mysql/mysql-delete-query.htm

    You just have to know which query to send to mysql and you can tweak base on the php scripts arcadEd provided.

    Thanks so much i can delete all data from example <img src="smileys/smiley32.gif" border="0" align="middle" />    <img src="smileys/smiley17.gif" border="0" align="middle" />   <img src="smileys/smiley17.gif" border="0" align="middle" />   <img src="smileys/smiley17.gif" border="0" align="middle" />

    Thanks so much again. also sorry ArcadEd <img src="smileys/smiley1.gif" border="0" align="middle" />

    I add my delete code below.

    <?php

    $dbhost = 'localhost';

    $dbuser = 'database name';

    $dbpass = 'password';

    $conn = mysql_connect($dbhost, $dbuser, $dbpass);

    if(! $conn )

    {

    die('Could not connect: ' . mysql_error());

    }

    $sql = 'DELETE FROM scores

            WHERE score';

    $sql = 'DELETE FROM scores

            WHERE name';

    $sql = 'DELETE FROM scores

            WHERE id';

    mysql_select_db('database name');

    $retval = mysql_query( $sql, $conn );

    if(! $retval )

    {

    die('Could not delete data: ' . mysql_error());

    }

    echo "Deleted data successfully\n";

    mysql_close($conn);

    ?>

  • Guero you shouldn?t just give c2 an String.

    You should better use Arrays.

    but ok for deleting just make an new php file with 1 command:

    mysql truncate table

  • LOl

    Edit: Sry you already found a way for that.

  • Glad that you got it work out. However there's some problem on this script.

    Line1: $sql = 'DELETE FROM scores

                   WHERE score';

    Line2: $sql = 'DELETE FROM scores

                   WHERE name';

    Line3: $sql = 'DELETE FROM scores

                   WHERE id';

    $retval = mysql_query( $sql, $conn );

    Doing so will only send query of Line3 to server. which actually Line 1&2 is useless. You can google up MySQL query to read up on how to combine things like "DELETE FROM scores WHERE score=100 AND name='me' AND id=1".

  • Yes Thanks i understand but now it works fine as i want <img src="smileys/smiley1.gif" border="0" align="middle" /> no problem. i will not use this feature for score or any game option i think use with geolation <img src="smileys/smiley1.gif" border="0" align="middle" />

    Thanks for interest   <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Glad you got it.

    I am no PHP expert by any means. In fact it's been several years since I did any real PHP programming so I am glad others were able to help.

    Also weird that I never got notified that I was tagged in this post. Weird.

  • Jump to:
    Active Users
    There are 1 visitors browsing this topic (0 users and 1 guests)