Forum Moderators: coopster
We are implementing a giveaway contest in which people are limited to one entry per day.
The code I now have for that portion, which compares today's date with the date in the database based on first name, last name is as follows:
// Connect to MySQL database
require_once ('../Connections/mysql_connect.php');
// ------------------------
// Let's make sure the name has only been entered once today
// set today's date
$today_date = date(Y."-".m."-".d);
// retrieve the old date in the database based on first name, last name
$query = ("SELECT date_submitted FROM giveaway WHERE firstName = '$firstName' AND lastName = '$lastName'");
$result = mysql_query($query) or die("Error in query:".mysql_error());
$old_date = $result;
echo $old_date; // I echo'd this and found it prints Resource id3, not the date
// if there is a match
if ($old_date > 0) {
// compare old date with today's date; if dates are the same
if ($old_date == $today_date) {
echo "<p><font size=2 face=Arial, Helvetica, sans-serif>Sorry, we are unable to accept your entry at this time. Our records indicate that you have already entered our Giveaway contest today.<br>\n
Please try again tomorrow. If this is incorrect or you have questions, please contact support@ourdomainhere.com.</font></p>";
exit(); // exit the script so it won't create an entry
}
}
// ------------------------
Since in testing there is no error concerning same-day submissions, I echoed out the $old_date variable and found it prints Resource id3 instead of the date that's in the database.
Any ideas on why?
Any help is most appreciated, as I'm very stuck on this and need to get moving on the project.
Thanks,
ksp
[edited by: jatar_k at 4:51 pm (utc) on June 4, 2004]
[edit reason] fixed sidescroll [/edit]