2

I have a game created in ActionScript 3 which uses a MySql database / PHP to store and reload the game state between player logins. I have strings(varchars), ints, big ints etc being saved. On my local WAMP server this seems to work perfectly. On upload however, my host database will not store the strings. It will store strings used for the login / registration (username, email etc) but not the strings created for some of the game data ( a game character's color, gender, hair style, shoes etc are stored as one long string). I have a php file which deals with login and registration and a second dealing with all game store / load, plus a number of AS3 interface classes which talk to this php file. But the same AS3 class / php file will successfully store ints etc whilst failing to store string data. I checked the column names and that the local and host databases are identical, and have set the collation to utf8_bin for all the string fields in case there was some sort of collation issue. I am new on databases...

In the php I am using something like:

$id=$_POST['userId'];
$value1=$_POST['array1'];
$value2=$_POST['array2'];
$what=$_POST['action'];
if ($what === 'storeStuff'){
mysqli_query($db,"UPDATE mytableName SET field1=$value1, field2=$value2 WHERE userid='$id'") or exit("systemResult=fail");
exit("systemResult=success");
}

Here is an example of the type of string info being saved successfully in my local database table, but which gives me a 'systemResult = fail' on my hosted database:

0,1,0|0,0,3|0,1,0|0,1,1

Any ideas what is going on? Thank you.

ruth
  • 21
  • 1
  • Typically with strings they need to be enclosed in single quotes and integers do not need to be. I'm noticing that you have these reversed; Can you verify this information? – nomistic Apr 14 '15 at 15:00
  • Echo the query before executing it from the code, and try to manually execute it on both DBs. – Jehad Keriaki Apr 14 '15 at 15:21

1 Answers1

0

I resolved my problem after 'phoning a friend' who suggested I look at the 'magic quotes' issue, and add some code to check if they were turned on in the host server and if so, turn off. He was right. Turns out it was the quotes surrounding the strings which were causing a problem, as different server configurations / versions will cause differing results. To ensure a consistent result independent of server configuration / version I used the solution offered in the php.net manual.

Here is the link I used which includes the needed code to identify their status and disable them.
http://php.net/manual/en/security.magicquotes.disabling.php

ruth
  • 21
  • 1