array_map() probably obvious mistake

Posted on 16th Feb 2014 07:03 pm by admin

The code below is part of a class to escape strings, but should also accept an array, using array_map() to do the job. Unfortunately, passing an array results in the original, unescaped array being returned - can't figure out why? If you uncomment the echo statement, it is outputting the correct escaped string for each element of the array, so the callback is definitely happening.

public function escape_str($str)
if (is_array($str))
if (get_magic_quotes_gpc()) {
$str = stripslashes($str);
if (!is_numeric($str)) {
$str = "'" . mysql_real_escape_string($str) . "'";
//echo $str.'<br />';
return $str;

$xt = array("' OR ''=''",'"abcdefg"');

Outputs original array, not escaped!

Can anyone help with this? Thanks.

No comments posted yet

Your Answer:

Login to answer
204 Like 21 Dislike
Previous forums Next forums
Other forums

help with contest script
I would like to code a contest script to my site but i don't know how. Could someone just give me pu

Downloading file (Headers)
I'm trying to make users download a file, but they must wait 60 seconds before it begins.


Google voice
I currently have a form in html, but I want it in php so the information is not in the source code.<

Not adding to db
Hi, I can't figure out why it won't add the record to the database. It's just a simple form to get

Simple Scraper... Weird Output
Okay, maybe I just need a Blue Monster and some sleep, but....

I'm scraping a ringtone site

ScriptResource.axd gives an error on fresh install of ASP.NET Ajax 1.0
Hello,I have a fresh install of Microsoft ASP.NET Ajax 1.0. When I create an Ajax enabled website in

PO Release Strategy Issue
Hi Experts,

I am facing an issue related to PO release strategy. The details are-

XML Grouping
I'm using xml_parse_into_struct to get all my elements, but now I need to group them. For example, h

Hi all,

I have an advanced basic knowledge of php

I want to try something new for a s

how to make database item unique
Hey guys,

is it possible to do this:

I have the database item $title being pulled for

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS

Play Free Quiz and Win Cash