Hello everyone,
I've been scanning the post and have only gathered pieces of what I'm looking for. I'm also new to this. So I'm hoping someone can help me. I'm using Mysql and I need a query that lets me check my db to see if the field is already in the db, and if not insert the row. But if it is, do not insert, just echo. And the other problem is that I don't quiet understand how to insert the current time and date. This is the query I use now but it doesn't check to see if the row is already there and I get zero's inserted into the db where I want the current time and date to automatically insert.
<?php
$id = "$0";
$ref = "$r";
$fn = "$fn";
$e = "$e";
$t = "$t";
$dbh=mysql_connect ("localhost", "mydbname", "mypassword") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("mydbname");
$query = "insert into mytable values ('$id', '$r', '$fn', '$e', '$t', '$timestamp', 'now()')";
$result = mysql_db_query ("mydbname", $query);
if ($result){
echo "Your Subscription Has Been Confirmed. Click on this link to download your free bonus gifts.";
}
else{
echo mysql_errno().": ".mysql_error()."<BR>";
}
mysql_close ();
?>
My varibles $r, $fn, $e, $t are tranfered into the page thru a string from an email response. The $0 varible is for the auto incrment field that I have in the first column of the table. And I notice from the post that I scanned (looked over) that I may need an unique index.
Would someone please share some knowledge with me on this problem. I hope this is clear.
Thank In Advance!
🙂