Missing '+' on Ajax post

0 favourites
  • 7 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Hello friends.

    I know this might be a php related issues,

    But maybe someone can help me :).

    I try to post a URI DATA string with the Ajax plugin to a php script, I

    request the data and insert it then in my mysql DB,

    and almost everything works fine. but my string in the database missing all the '+' sign?

    Sorry my bad English,

  • The + sign is a shortcut for spaces (which can't be used in a url). If you want to use an actual plus sign, be sure to htmlencode the string before sending. It will convert anything that is a special character into it's character code. htmldecode on the php side before inserting into the database.

  • hey <font color="red">theubie</font>, I owe you a beer.

    thank you so much for your prompt response, you were absolutely right and everything works fine now <img src="smileys/smiley32.gif" border="0" align="middle">

    I found this plugin Extra expressions and could encode my string to a base64 string before sending :) <font color="red">red</font>

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Construct 2 has built-in URLEncode and URLDecode expressions, you need to use them when posting AJAX requests.

  • thanks for the reply Ashley, I think I was too tired :)

    but I have now been on google and read a bit about the difference between urlencode VS base64encode and thought I could see that base64encode is better to handle special characters? But I'm not expert in php and do not know if this is a correct way to do it `?

  • I use the built in urlencode from C2 to encode and the htmlspecialchars_decode function on the php side for our Ajax transfers for UWE and it works just fine.

    Also, just as a side tip make sure you're sanitizing anything you're putting in the database to prevent injection attacks. mysqli_real_escape_string or something similar.

  • Big thanks to theubie and Ashley, I have now switched to the built-in plugin instead of Extra expression, and it works perfectly. But when my request is very large, I got problems when I tested locally, I have uploaded it to my server and everything works now :)

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