Timo,

 This is just an idea.  How about using the get_defined_vars() function,
 extracting the desired user defined variables, storing them in one array,
 and then sending that array as the single parameter to your sqlSafe()
 function?

 http://www.php.net/manual/en/function.get-defined-vars.php

 Good luck,
 Kevin


> ----- Original Message -----
> From: "Timo Ewalds" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, August 27, 2002 11:21 PM
> Subject: [PHP] variable reference parameters
>
>
> > I've created (with help from some code from the site) a function to make
> > strings or arrays mysql safe. It works just fine, assuming you pass your
> > variables by reference ( sqlSafe(&$var) ), but I get this error every
time
> > it is used:
> >
> > [error] PHP Warning:  Call-time pass-by-reference has been deprecated -
> > argument passed by value;  If you would like to pass it by reference,
> modify
> > the declaration of [runtime function name]().  If you would like to
enable
> > call-time pass-by-reference, you can set allow_call_time_pass_reference
to
> > true in your INI file.  However, future versions may not support this
any
> > longer.  in file.php on line X
> >
> > I want the function to be able to accept as many variables as needed to
> make
> > them sqlsafe (10 is enough for now), and to remove that annoying error,
> I'd
> > also like to not need to pass them by reference. Is this possible?? and
if
> > so, how?? I know it is possible to add the & before each function
> parameter,
> > but then I can't pass more or less variables than I put in the function
> > definition, cause you can't have default values for a reference
parameter
> > (go figure), and it'll also complain if you give it too few variables.
> >
> > function sqlSafe( $a0,
> >      $a1=NULL,
> >      $a2=NULL,
> >      $a3=NULL,
> >      $a4=NULL,
> >      $a5=NULL,
> >      $a6=NULL,
> >      $a7=NULL,
> >      $a8=NULL,
> >      $a9=NULL){
> >  if(func_num_args()>10)
> >   echo "<h1>Too Many Args in sqlSafe</h1>";
> >  for($i=0;$i<func_num_args();$i++){
> >   $name="a" . $i;
> >   if(!isset($$name)) continue;
> >   if(is_array($$name)){
> >    foreach($$name as $n => $v){
> >     if(is_array($v))
> >      sqlSafe(&${$name}[$n]);
> >     elseif(isset($v))
> >      ${$name}[$n] = mysql_escape_string ($v);
> >    }
> >   }else
> >    $$name = mysql_escape_string ($$name);
> >  }
> > }
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to