[PHP] array_map help

2006-02-17 Thread Mark Steudel
I've got the following code and I am not doing something right. Either my
function is wrong, or the way Im using array_map is wrong, as slashes are
still making it into the data, and the asdf iosn't getting appended to each
value.

Thanks, Mark



// function to remove stripped slashes
function detectMGQ($value)
{
   // Stripslashes
   if (get_magic_quotes_gpc()) {
   $value = stripslashes($value);
   }
   
// added in to detect if this function is working
   $value .= $value.'asdf';

   return $value;
}

// construct field and value pairs into array
$field_values   =   array(  'name'  = $clean[name],
'email' =
$clean[email],
'username'  =
$clean[username],
'accesslevel'   =
$clean[accesslevel],
'status'=
$clean[status],
'password'  =
base64_encode(rc4($clean[password1])) );


// walk through the values and strip out the slashses
$field_values = array_map( detectMGQ, $field_values );

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



Re: [PHP] array_map help

2006-02-17 Thread Jochem Maas

Mark Steudel wrote:

I've got the following code and I am not doing something right. Either my
function is wrong, or the way Im using array_map is wrong, as slashes are
still making it into the data, and the asdf iosn't getting appended to each
value.


I rewrote what you had like so:

?php
function detectMGQ($value)
{
   //return get_magic_quotes_gpc() ? stripslashes($value): $value;
   return $value.-TEST;
}

$clean = array(
name  = name,
email = email,
username  = username,
accesslevel   = accesslevel,
status= status,
);

$field_values = array_map( detectMGQ, $clean );
var_dump($field_values);
?

and it adds '-TEST' to every value as expected. not sure whats going
wrong with your code exactly by I have got some general comments...
(maybe the code I rewrote helps you to figure otu what was/is going
wrong.)



Thanks, Mark



// function to remove stripped slashes
function detectMGQ($value)
{
   // Stripslashes
   if (get_magic_quotes_gpc()) {
   $value = stripslashes($value);
   }
   
// added in to detect if this function is working

   $value .= $value.'asdf';


if $value equals ABC then it would equal ABCABCasdf aftyer
that last line of code was run.



   return $value;
}

// construct field and value pairs into array
$field_values   =   array(  'name'  = $clean[name],
'email' =
$clean[email],


  yuou don't need to wrap $clean[email] in quotes - it's waste of
time+cpu BUT you should always delimit the array key with quotes because
it is a string not a constant (or does you code actually define a constant
named 'email'?) i.e.

$clean[email] is better off being $clean['email']


'username'  =
$clean[username],
'accesslevel'   =
$clean[accesslevel],
'status'=
$clean[status],
'password'  =
base64_encode(rc4($clean[password1])) );


// walk through the values and strip out the slashses
$field_values = array_map( detectMGQ, $field_values );



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



RE: [PHP] array_map help

2006-02-17 Thread Mark Steudel
Thank you I will give it a try. 

-Original Message-
From: Jochem Maas [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 17, 2006 9:24 AM
To: Mark Steudel
Cc: php-general@lists.php.net
Subject: Re: [PHP] array_map help

Mark Steudel wrote:
 I've got the following code and I am not doing something right. Either 
 my function is wrong, or the way Im using array_map is wrong, as 
 slashes are still making it into the data, and the asdf iosn't getting 
 appended to each value.

I rewrote what you had like so:

?php
function detectMGQ($value)
{
//return get_magic_quotes_gpc() ? stripslashes($value): $value;
return $value.-TEST;
}

$clean = array(
 name  = name,
 email = email,
 username  = username,
 accesslevel   = accesslevel,
 status= status,
);

$field_values = array_map( detectMGQ, $clean ); var_dump($field_values);
?

and it adds '-TEST' to every value as expected. not sure whats going wrong
with your code exactly by I have got some general comments...
(maybe the code I rewrote helps you to figure otu what was/is going
wrong.)

 
 Thanks, Mark
 
 
 
 // function to remove stripped slashes function detectMGQ($value) {
// Stripslashes
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}

 // added in to detect if this function is working
$value .= $value.'asdf';

if $value equals ABC then it would equal ABCABCasdf aftyer that last
line of code was run.

 
return $value;
 }
 
 // construct field and value pairs into array
 $field_values =   array(  'name'  = $clean[name],
   'email' =
 $clean[email],

   yuou don't need to wrap $clean[email] in quotes - it's waste of
time+cpu BUT you should always delimit the array key with quotes because
it is a string not a constant (or does you code actually define a constant
named 'email'?) i.e.

$clean[email] is better off being $clean['email']

   'username'  =
 $clean[username],
   'accesslevel'   =
 $clean[accesslevel],
   'status'=
 $clean[status],
   'password'  =
 base64_encode(rc4($clean[password1])) );
   
 
 // walk through the values and strip out the slashses $field_values = 
 array_map( detectMGQ, $field_values );
 

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



RE: [PHP] array_map help

2006-02-17 Thread Mark Steudel
I figured out that nothing was wrong with this (other than the other things
you pointed out) and that I was just uploading the wrong file to the wrong
place ... oops

Thanks again, Mark 

-Original Message-
From: Jochem Maas [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 17, 2006 9:24 AM
To: Mark Steudel
Cc: php-general@lists.php.net
Subject: Re: [PHP] array_map help

Mark Steudel wrote:
 I've got the following code and I am not doing something right. Either 
 my function is wrong, or the way Im using array_map is wrong, as 
 slashes are still making it into the data, and the asdf iosn't getting 
 appended to each value.

I rewrote what you had like so:

?php
function detectMGQ($value)
{
//return get_magic_quotes_gpc() ? stripslashes($value): $value;
return $value.-TEST;
}

$clean = array(
 name  = name,
 email = email,
 username  = username,
 accesslevel   = accesslevel,
 status= status,
);

$field_values = array_map( detectMGQ, $clean ); var_dump($field_values);
?

and it adds '-TEST' to every value as expected. not sure whats going wrong
with your code exactly by I have got some general comments...
(maybe the code I rewrote helps you to figure otu what was/is going
wrong.)

 
 Thanks, Mark
 
 
 
 // function to remove stripped slashes function detectMGQ($value) {
// Stripslashes
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}

 // added in to detect if this function is working
$value .= $value.'asdf';

if $value equals ABC then it would equal ABCABCasdf aftyer that last
line of code was run.

 
return $value;
 }
 
 // construct field and value pairs into array
 $field_values =   array(  'name'  = $clean[name],
   'email' =
 $clean[email],

   yuou don't need to wrap $clean[email] in quotes - it's waste of
time+cpu BUT you should always delimit the array key with quotes because
it is a string not a constant (or does you code actually define a constant
named 'email'?) i.e.

$clean[email] is better off being $clean['email']

   'username'  =
 $clean[username],
   'accesslevel'   =
 $clean[accesslevel],
   'status'=
 $clean[status],
   'password'  =
 base64_encode(rc4($clean[password1])) );
   
 
 // walk through the values and strip out the slashses $field_values = 
 array_map( detectMGQ, $field_values );
 

--
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