Hi..
I'm trying to build a keyword logger for my search engine, and I'm running across a couple of problems..
Ok, here's what I want to do, basically..
1.) Script connects to db and checks to see if term is already there.
2.) if term is there, then add 1 to the "count" field and update db.
3.) if term is not there, add term to db.
Now, the fun part is, I don't want to log any words less than 4 letters... I figured out that part, but I'm having problems sorting out the logic needed to check/update/create new data. Here's the snippet of code I'm trying to use (it's WAY wrong, I know)
if(strlen($term)>3){
$db=mysql_connect("$dbhost","$dbuser","$dbpasswd");
$query = mysql_query("SELECT term, count FROM terms WHERE Term like $term;");
$entry = @mysql_fetch_array($query);
$new_count = $entry["count"]+1;
$update = mysql_query("UPDATE terms SET term = $new_count, WHERE Term like $term;");
mysql_close($db);
} else {
if(strlen($entry)=0)
$new_count = mysql_query("INSERT into links ID, Term, count VALUES('','$term',''");
}
mysql_close($db);
Any help would be greatly appreciated!