My webpage runs the following excerpt every time someone goes to it. My query goes out to the referrals table and checks to see if a particular row has a date in the “arrived” column. If “arrived” is null, then my script attempts to do an insert into another table. The problem is that its doing the insert every time the page is loaded, even when that particular referral already has an “arrived” date. Can someone help me figure out what I’m doing wrong?
Thanks!
$alreadyLogged = “SELECT arrived FROM referrals WHERE rID = ‘$rID’”;
$result = mysql_query($alreadyLogged) or die("<b>A fatal MySQL error occurred</b>.
<br />Query: " . $sql . “<br />
Error: (” . mysql_errno() . ") " . mysql_error());
$row = mysql_fetch_row($result);
$arrived = $row[“arrived”];
if (is_null($arrived)) {
mysql_query($insertNotification) OR die("<b>A fatal MySQL error occurred</b>.
<br />Query: " . $insertNotification . “<br />
Error: (” . mysql_errno() . ") " . mysql_error());
}