PDA

View Full Version : escaping character for amfphp



jazgold
May 1st, 2007, 04:54 PM
amfphp is supposed to be easy. for the most part, it is. i love that i can send arrays of arrays and not worry about anything.

i am having trouble though with some things that would be otherwise very basic just POSTing to a php script directly...

when i send a string containing a single quote ( ' ) and try and use it in a mysql query, the query will fail. addslashes() does not work.

i noticed in the amfphp "common errors" documentation says:


AMFPHP uses $HTTP_RAW_POST_DATA as its input. This variable is not affected by magic quotes. Thus all your service arguments will act as though magic quotes was set to off. If you try to insert something with a quote in it without escaping it you will receive an error back from your sql driver. Use the database specific escaping function on your strings before running SQL, for example mysql_real_escape_string for MySQL.so i tried running



mysql_real_escape_string( $val ) or die("problem trying to escape");
$sql = "UPDATE $tableName SET `$fieldName`='$val' WHERE `item_id`='$id' LIMIT 1";
and if $val contains a single quote, then the script dies at the escaping.

any ideas?

ever seen this before?

thanks

jaz

duncanhall
May 1st, 2007, 05:10 PM
Have you tried using the service browser to have a look at how Flash is sending the strings to your service?

jazgold
May 1st, 2007, 05:53 PM
let me update that...

it's not even a problem with escaping a mysql command...

when i send a param to amfphp like "we're going crazy"

in the amfphp function, the param will come up blank... the param is just coming up blank if it contains an apostrophe... wtf... amfphp error?

............i don't want to replace all my amfphp calls with sendAndLoads... that would be pretty depressing.

jazgold
May 1st, 2007, 06:08 PM
Have you tried using the service browser to have a look at how Flash is sending the strings to your service?


even when i send the value directly through the service browser, it doesn't work. i'm not even going through flash.

jpq
April 11th, 2008, 09:47 AM
even when i send the value directly through the service browser, it doesn't work. i'm not even going through flash.

Hello jazgold,

Apologies for the old thread but.....

Totally stuck at the moment.:puzzle:

Did you ever find a solution?

rondog
April 30th, 2009, 08:55 PM
I am actually having this problem too...any solutions??

rondog
April 30th, 2009, 08:59 PM
nevermind just found the answer...



var a:String = "we're going home.";
var b:String = escape(a);
trace(b); //we%27re%20going%20home.
trace(unescape(b)); //we're going home.