/    Sign up×
Community /Pin to ProfileBookmark

I have a simple table in my db it’s called words it has one colum called Autofill in that colum there are a bunch of keywords and each client can set thier keywords and it updates that table unless that word all ready exists in the table. it it does exist it is suposed to replace the word and not have a duplicate.

[code=php]$wordarray = explode(” “,trim($keywords));
//$wordquery = implode(“‘), “,$wordarray);
$sqlvalues .= “VALUES (‘”.implode(“‘), (‘”,$wordarray).”‘)”;
$ignorequery = “REPLACE `Chamber_DB`.`words` (`Autofill`) $sqlvalues”;
//print_r($wordarray);
//echo($ignorequery);
//echo($sqlvalues);
$result = mysql_query ($ignorequery) or die(“Error ” . mysql_errno( ) . ” : ” . mysql_error( ));
if ($result==true){
echo “The Words Database Has Been Updated”;
}
else
{
echo “The Words Database was not updated!”;
}
[/code]

Problem is it is inserting the words into the table but I am getting dulicates so the replace query is not working

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@janusmccarthyMay 22.2010 — Don't know off the top of my head, but you can force uniqueness by making the word column unique in your mysql table.
×

Success!

Help @hotrodjeremy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...