php-windows Digest 30 Jun 2007 21:46:29 -0000 Issue 3271
Topics (messages 28161 through 28163):
Re: array walk?
28161 by: Michael Southworth
MySQL query error
28162 by: James Blandford
28163 by: James Blandford
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Looks like the answer is in the manual entry for array_walk_recursive
http://php.net/array_walk_recursive
*Note: * If *funcname* needs to be working with the actual values of the
array, specify the first parameter of *funcname* as a
reference<http://www.php.net/manual/en/language.references.php>.
Then, any changes made to those elements will be made in the original array
itself.
Try using a wrapper around strip_tags which tags a reference as its first
argument
function array_walk_strip_tags(&$string){
$string = strip_tags($string);
}
PHP is essentially only passing a copy of $a[i] and stripping the tags from
the copy without changing the actual values of $a. Passing by reference
ensures that you modify the entries in $a itself. How this is handled below
the hood is slightly more complex and I don't have a ton of experience with
how PHP specifically handles that sort of thing, but it looks like that will
at least point you in the right direction.
-Michael
On 6/28/07, Juan Ignacio Borda <[EMAIL PROTECTED]> wrote:
this code doesn't work on my PHP Version 5.2.1 (i'm trying to protect a
stie from XSS)
<?php
$a=Array();
$a[]='<i>como</i>';
$a[]=Array('<b>hola</b>','hello');
array_walk_recursive($a,'strip_tags');
echo "<pre>";
var_dump($a);
echo "</pre>";
?>
it outputs:
<pre>array(2) {
[0]=>
string(11) "<i>como</i>"
[1]=>
&array(2) {
[0]=>
string(11) "<b>hola</b>"
[1]=>
string(5) "hello"
}
}
</pre>
any clues?
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hello,
I am making a private messaging system for my website, and if you click on
the pm, it --should-- set it as "read" rather than "unread". I am using the
query:
UPDATE pms SET read=1 WHERE id='{$assoc['id']}'
but it is giving me this error:
You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'read=1 WHERE
id='4'' at line 1
To me, this query looks perfectly fine, but obviously it isn't. Please can
you tell me how to make it work.
Cheers,
James
--- End Message ---
--- Begin Message ---
Hello,
I am making a private messaging system for my website, and if you click on
the pm, it --should-- set it as "read" rather than "unread". I am using the
query:
UPDATE pms SET read=1 WHERE id='{$assoc['id']}'
but it is giving me this error:
You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'read=1 WHERE
id='4'' at line 1
To me, this query looks perfectly fine, but obviously it isn't. Please can
you tell me how to make it work.
Cheers,
James
--- End Message ---