MySQL Forums
Forum List  »  PHP

Re: single quote in data breaks file load
Posted by: Roland Bouman
Date: July 27, 2005 08:39AM

Yes, just walk the array yourself.

Define a function like this (array 'pointer' style):

function my_mysql_real_escape_array(
&$data
){
foreach($data as &$value){
$value = mysql_real_escape_string($value);
}
}

This should modify each element in the array.
Now, replace the array_walk invocation in the earlier post with a call to this function:

while (...){
my_mysql_real_escape_array($data);
list(..) = $data;
}


If the references keep bugging you, define the function like so (array copy style):

If this gives a problem, instantiate a new array:

function my_mysql_real_escape_array(
$data
){
$escaped_array = array();
foreach($data as $key => $value){
$escaped_array[$key] = mysql_real_escape_string($value);
}
return $escaped_array;
}

and write the invocation like so:

while (...){
$data = my_mysql_real_escape_array($data);
list(..) = $data;
}

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.