/    Sign up×
Community /Pin to ProfileBookmark

i am trying to retrieve fields from a database that will bring all rows where payment is either due within the next 7 days or overdue using the following code

[code=php]$week=time()+604800;
$week=date(“Y-m-d”,$week);
$query=mysql_query(“SELECT * FROM users WHERE paydate<=$week ORDER BY paydate DESC”);[/code]

but this doesnt work at all, any ideas

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@unknown_strikerFeb 18.2004 — Maybe try putting $week in single quotes? ie.

[code=php]$query=mysql_query("SELECT * FROM users WHERE paydate <= '$week' ORDER BY paydate DESC");[/code]


C
Copy linkTweet thisAlerts:
@nutheadauthorFeb 19.2004 — thats the way i had it before, i deleted the quotes to see if that worked instead but forgot to put them in :rolleyes:
Copy linkTweet thisAlerts:
@nutheadauthorFeb 19.2004 — sorry to bump but can anybody help me at all? i need to know urgently!!
Copy linkTweet thisAlerts:
@nkegFeb 21.2004 — I'm not sure, but try
[code=php]$query=mysql_query("SELECT * FROM users WHERE paydate=$week ORDER BY paydate DESC");[/code]
Copy linkTweet thisAlerts:
@nutheadauthorFeb 21.2004 — its ok, i figured it out i changed

$week=date("Y-m-d",$week);

to

$week=date(Ymd,$week);

it was treating the $week var as a string, not a number :rolleyes:
×

Success!

Help @nuthead spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...