/    Sign up×
Community /Pin to ProfileBookmark

comparing dates

Hi, I get:

[QUOTE]

Fatal error: Can’t use function return value in write context in C:xampphtdocs

[/QUOTE]

from following code: I just want to determine “dayslate”.
/

[code=php]/———

$dayslate = CURDATE() = DATE(duedate);

// $dayslate = DATE(NOW()) – DATE(duedate);
//———
// QUERY ON tablename TABLE
$query = “SELECT dayslate,
——————————–[/code]

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMay 20.2015 — Looks like you're trying to combine PHP and SQL in one command, which ain't gonna work. Perhaps we (or at least I) need a wee bit more context?
Copy linkTweet thisAlerts:
@12StringsauthorMay 20.2015 — This is the entire code. I'm just trying to create a report displaying a [B]days late[/B] field.

[code=html]<!DOCTYPE html><html>
<head>
<STYLE TYPE="text/css">
.blue {background-color: #ccffff;}
.tan {background-color: #FFD4FF;}
h1.centered-cell {text-align: center;font-size: 1.1em;}
</STYLE>
</head><body><center>[/code]


[code=php]<?php
error_reporting(E_ALL ^ E_NOTICE);
// error_reporting(0);
// CONNECT TO THE DATABASE
$DB_NAME = 'homedb';$DB_HOST = 'localhost';$DB_USER = 'root';$DB_PASS = 'cookie';
$mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
if (mysqli_connect_errno())
{printf("Connect failed: %sn", mysqli_connect_error());exit();}
//---------
$dayslate = CURDATE() = DATE(duedate);
// $dayslate = DATE(NOW()) - DATE(duedate);
//---------
// QUERY ON "oocust" TABLE
$query = "SELECT acctno, status, pd, payrec, bname, duedate, datepaid, purpose, dayslate, amtdue
FROM oocust WHERE payrec = 'R' AND pd = 'N'";
$result = $mysqli->query($query) or die($mysqli->error.__LINE__);
echo "<center>";
?> [/code]

[code=html]<h1 class="centered-cell">Accounts Receiable Report</h1><br>
<table cellspacing=0 cellpadding=2 border=1>
<thead>
<tr>
<th colspan=4></th>

<th class="blue">date</th>
<th class="blue">days</th>
<th class="blue">amt</th>
<tr>
<th class="blue">recur?</th>
<th class="blue">acct#</th>
<th class="blue">debtor</th>
<th class="blue">purpose</th>
<th class="blue">due</th>
<th class="blue">late</th>
<th class="blue">due</th>
</tr>[/code]

[code=php]<?php
// Associative array
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
{

// if($dayslate > 120)
// {$pastdue = "pastdue";}
$totdue += $row['amtdue'];
$gtotal += $row['amtdue'];
echo '
<tr>
<td>', $row['status'], '</td>
<td>', $row['acctno'], '</td>
<td>', $row['bname'], '</td>
<td>', $row['purpose'], '</td>
<td>', $row['duedate'], '</td>
<td>', $row['dayslate'], '</td>

<td align=right class="currency">$'.number_format($row['amtdue'],2).'</td>

</tr>';
}

echo '
<tr>
<th bgcolor="#ccffff" scope="row" colspan="6">Grand Total:</th>
<td bgcolor="#FFD4D4" class="currency">$'.number_format($totdue, 2, '.', ''), '</td>
</tr>
</table>';

?>[/code]

[code=html]

</body></html> [/code]
Copy linkTweet thisAlerts:
@NogDogMay 21.2015 — I think maybe you want something like this?
[code=php]
$query = "
SELECT
acctno,
status,
pd,
payrec,
bname,
duedate,
datepaid,
purpose,
DATEDIFF(CURDATE(), duedate) AS dayslate,
amtdue
FROM oocust
WHERE payrec = 'R' AND pd = 'N'";
[/code]
Copy linkTweet thisAlerts:
@12StringsauthorMay 22.2015 — I think maybe you want something like this?
[code=php]
$query = "
SELECT
acctno,
status,
pd,
payrec,
bname,
duedate,
datepaid,
purpose,
DATEDIFF(CURDATE(), duedate) AS dayslate,
amtdue
FROM oocust
WHERE payrec = 'R' AND pd = 'N'";
[/code]
[/QUOTE]

great thanks so much
×

Success!

Help @12Strings 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.6,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...