Sr. Web Developer
mediabistro.com
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

Comments for: vaska20050722

Message # 1510840:
Date: 11/29/08 09:09
By: nikosch
Subject: more Bugs and Tips

#2
First, there is a closing bracket missing in this line:
if (is_array($post) {

Second, you should return the original value (return $post), if mq is turned off. Otherwise you need another if-clause to be sure, if mq was off or your parameterset simply was empty.

Much more interesting: This function only works with arrays up to 1 dimension. Look what happens else:
<?
set_magic_quotes_runtime (1);

$myArray = array (1 => array (1 , 2));
print_r (magicQuotes($myArray));
// outputs: Array ( [1] => Array )
// stripslashes uses the String representation of Array here
?>

use this instead:

<?
function magicQuotes($value)
{
if (get_magic_quotes_gpc()) {
return magicQuotesRecursive($value);
}
return $value;
}


function magicQuotesRecursive($value)
{
if (is_array($value)) {
return array_map('magicQuotesRecursive' , $value);
}
return stripslashes($value);
}

?>
The second function is only for not repeating the if (get_magic_quotes_gpc()) clause.

#4
Use the error_reporting always together with

ini_set('display_errors', 1);

to be sure, that errors will be displayed.

Previous Message | Next Message


Comments:
more Bugs and Tipsnikosch11/29/08 09:09
SQL InjectionsAllison M Nighswander10/05/08 23:47
I'm basically disagreeing with everything.Cthulhu07/01/08 17:30
Magic quotes are eeevil.Marnen Laibow-Koser06/20/07 17:17
Trying to connect to MySQL databaseEmmanuel Sey08/13/05 09:14
RE: Bug in tip #1vaaaska08/10/05 11:49
Why 10 when only 5?Kim08/09/05 16:46
Bug in tip #1Casper08/08/05 16:43
locating files in subfoldersJvandal08/02/05 11:26
i want to learnyinka08/01/05 11:21
RE: tutorial phpArun Mishra07/29/05 07:08
check box selectionarthur07/27/05 03:58
tutorial phplukman07/26/05 23:06
Its CoolMohammed Mizan Uddin07/26/05 01:41
I'm not sure...Toby07/25/05 13:12
Tip 5, better information.Mike Willbanks07/25/05 10:03
What about magic_quotes_sybase?Sergey Bres07/25/05 09:48
 

If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.