I think you need to use UPDATE instead of INSERT. This is a name column that already holds a "name" value, is it not (I assume so, since we're checking against it)?
[not tested]
PHP Code:
<?php
foreach ($xml->xpath('//prod') as $character) {
$name = $character["name"];
mysql_query("UPDATE xml SET name = '$name' WHERE name NOT LIKE 'Tom'") or die(mysql_error());
}
however, I suspect this won't do what you expect. (I don't think your original code would, either, if it did work.) It would loop through all the new names, but each UPDATE would be performed on the entire table. So, you'd end up with everyone's name being set to the name of the last character to go through the foreach loop (except for the characters named Tom, of course).
Try incorporating thetestingsite's suggestion - compare the existing name first, then make a more specific replacement:
[not tested]
PHP Code:
<?php
foreach ($xml->xpath('//prod') as $character) {
if(strtolower($character['name']) != 'tom'){
$name = $character["name"];
mysql_query("UPDATE xml SET name = '$name' WHERE id = '$character['id']'") or die(mysql_error());
}
}
Bookmarks