Thank you all for your input. I got a solution based around array_walk and addslashes. But Dave Goodwin mentioned escape_string (in my case pg_escape_string) and in the manual it says use of escape_string is recommended in preference to addslashes. Anyone know why, or what the differences are? alan dunn