I have a piece of code as follows:
$query = preg_replace('/\<a href=\"(.*)\"\>\<img height=\"(\d+)\" border=\"0\" width=\"(\d+)\" alt=\"(.*)\" src=\"(.*)\" \/\>\<\/a\>/',"INSERT INTO newproducts (productName,supplierName,productLink,imageLink,groupCode,currency,price,updated) VALUES ('$4','supplier','$1','$5',",$ad); $query .= "'$group','\$',$price,CURRENT_DATE)";
which works fine. But I would like somehow to amend it so that the field productName ($4) can have slashes added to it where necessary, specifically where there are single quotes. It's not absolutely vital, but would definitely be helpful, as it saves having to look at the text and add slashes manually (as this works on an ad input by an operator).