Just can’t get this to work. I want to check if this user bought a $45 or more bid pack in the last 7 days.
$big_amount="45";
//check if the user has purchased bids
$strFind="SELECT * FROM `prepaypal` WHERE `memid`=\"$curmemid\" AND `success`='Y'
AND `pid`='0' AND `amount`>=\"$big_amount\" BETWEEN NOW() and DATE_SUB
(`date`, INTERVAL 7 DAY) ORDER BY `date` DESC LIMIT 1";
//echo $strFind;
$result=mysql_query($strFind) or die(mysql_error());
$row=mysql_fetch_array($result);
$bought_bids=$row['id'];
That select statement is not right at all, you should do it this way:
SYSDATE()returns the time at which the function executes and interval sets a time period between the given dates.It’s also better to optimize your queries and to get specific values off the database than to do
"SELECT *"For example:
SELECT Field1, Field2, Field3 from table;MySQL_ PHP functions are deprecated as well, so you shouldn’t use them anymore. I would stick to Mysqli or PDO prepared statements.
If this doesn’t qualify as a correct answer to you, feel free to downvote.