How do I get Construct 3 to read error from mysql?

  • Hi I am currently setting up my SQL for my leaderboard. I have been able to configure setup mysql to check for existing record when a new user tries to create a new username.

    Manually testing it, I am able to create a new user and also when I try to create another user with same name, it echos the message as expected on the browser.

    The challenge I have now is with Construct 3, I am able to create a new user but when I try to create same user, on SQL side nothing changes but on Construct 3 side, it still thinks it went OK.

    How can I get Construct 3 to get the echo message from mysql so it knows there was an error?

    if (mysqli_num_rows($res_u) > 0) { $name_error = "Sorry... username already taken"; echo 'Sorry... username already taken'; }else{ $sql = "INSERT INTO $db_name.$db_table (name, score) VALUES ('$name','$score')"; $results = mysqli_query($con, $sql); echo 'Your account has been created!'; }

    Tagged:

  • Are you using PHP and AJAX to send the request? Whatever you echo out should get sent back to C3 so you can tell if the results were "Sorry..." or "Your account..."

  • Are you using PHP and AJAX to send the request? Whatever you echo out should get sent back to C3 so you can tell if the results were "Sorry..." or "Your account..."

    Thanks for the reply. I just figured it out using AJAX.LastData then I am now able to compare the strings.

  • Are you using PHP and AJAX to send the request? Whatever you echo out should get sent back to C3 so you can tell if the results were "Sorry..." or "Your account..."

    If I may ask, how do I ensure no one is able to inject scores to the board using the full address?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • there is no easy or guaranteed way...

    using SSL helps make it harder for people to intercept requests. You can calculate a hash that the PHP script can use to check if the score is legitimate. But it is not very hard for people to reverse engineer that, or use programs to change the score to whatever they want inside your game (making the request look real to your database). All you can really do is try to discourage causal hackers - the good ones will always find a way.

    I have seen some pretty good suggestions on the forums over the years, but it might take some digging to find those posts now.

    monitor your database, and remove the obvious fake scores...

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