Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I can't seem to figure out where I'm going wrong here. This is what I have:

$query = ("SELECT * FROM contacts WHERE agentassigned = 'agent' AND reminder ='$reminder date("Y-m-d",strtotime("+7 day"))' ORDER BY firstname") or die ('Error: ' .mysql_error());
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
336 views
Welcome To Ask or Share your Answers For Others

1 Answer

MySQL will not execute the PHP code you sent it in the query.

That's probably not what you meant to do. Instead, concatenate the result of the date() call.

$query = "SELECT * FROM contacts WHERE agentassigned = 'agent' AND reminder ='$reminder " . date("Y-m-d",strtotime("+7 day")) . "' ORDER BY firstname";

Based on your comments, you actually want something like this:

SELECT 
  *
FROM
  contacts
WHERE
  agentassigned = 'agent'
AND
  reminder_date BETWEEN CURRENT_DATE AND CURRENT_DATE + INTERVAL 7 DAY

Where you need to add a column reminder_date to your table which contains the date of the reminder. You don't want to try to parse it out of a string like you're doing. It's slow and wrong.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...