>
>
> I want to be sure that all variables in the query are escaped. I don't
> trust myself or anyone else to do this to every variable right before
> the query:
> $someVar=mysql_real_escape_string($someVar);
>
>
But you're doing exactly that right before the query anyway with:

$M[username]=mysql_real_escape_string($username);

You're just complicating things with the addition of an unneeded array.  It
seems much simpler and less cluttered to just do:
          $someVar=mysql_real_escape_string($someVar);
before your insert.  All you are doing is changing "$someVar" to "$M[...]"
and then using $M[...] in the query.  I really don't see the difference or
benefit of using your array here.  Both methods are doing exactly the same
thing, except one is more convoluted.

Now on the other hand, if you have several elements in the array $M to be
inserted, and have a function like this to escape them all at once:

for each ($M as &$val)  $val= mysql_real_escape_string($val);

then your method starts to make more sense.

-Hank

Reply via email to