iluvperl
Programmer
- Jan 22, 2006
- 107
This is in Perl and I am getting an error near values( it says.
I'd like to use placeholders but it looks difficult to use with $dbh->do() as I am not particularly familiar with this.
What I need to do is sort of complicated for me, since I know basic MySQL stuff.
I need to check to see if "url" exists in the table "storage" and if it does, update it with new information. If it doesn't, I need to insert it.
I tried to do a SELECT first to check if it existed, but it errored out since it can't prepare an undefined value if it didn't already exist.
So I need help.
I'd like to use placeholders but it looks difficult to use with $dbh->do() as I am not particularly familiar with this.
Code:
$dbh->do("INSERT INTO storage (url, altavista, yahoo, msn, teoma, google, alltheweb,Total, lastsearch, totalsearch) values($url, $altavista_results, $yahoo_results, $msn_results, $teoma_results, $google_results, $alltheweb_results, $total,$time, $total)") unless $dbh->do(UPDATE storage SET (url = "$url", altavista = "$altavista_results", yahoo = "$yahoo_results", msn = "$msn_results", teoma = "$teoma_results", google = "$google_results", alltheweb = "$alltheweb_results", total = total +1, time="$time") > 0;
What I need to do is sort of complicated for me, since I know basic MySQL stuff.
I need to check to see if "url" exists in the table "storage" and if it does, update it with new information. If it doesn't, I need to insert it.
I tried to do a SELECT first to check if it existed, but it errored out since it can't prepare an undefined value if it didn't already exist.
So I need help.