-
Fatal error: Can't use function return value in write context
hiii i am new to php can any one check this
<html>
<head>
</head>
<body>
<form method="post">
<input type="date" name="startDate"></td>
<input type="date" name="endDate"></td>
<input type="submit" name="submit">
</body>
</html>
<?php
echo hi;
include"config.php";
echo $_POST[startDate];
echo $_POST[endDate];
$sql="INSERT INTO date VALUES ('','$_POST[startDate]','$_POST[endDate]')";
echo gregoriantojd($endDate)-gregoriantojd($startDate)=gregoriantojd($date);
?>
any help ....
-
-
This line doesn't work:
echo gregoriantojd($endDate)-gregoriantojd($startDate)=gregoriantojd($date);
You need:
echo gregoriantojd($endDate).'-'.gregoriantojd($startDate).'='.gregoriantojd($date);
Before you were using actual code: you were performing this math: a-b (so you get 3-2, which is 1), then you are SETTING x=y-- that means set X to Y.
So you were trying to set 1 (or whatever number) to the output of the function. Or, if the parsing order is = first then -, it would be trying to set the function itself to that function's output, giving a very strange error-- which is I think what you got.
Only variables (as far as I've ever seen) can be set:
$x = 5;
But doing
func(x) = func(y);
will cause a weird error.
By putting it in quotes, then you are outputting strings (text) rather than processing code.
Daniel -
Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
-
The Following User Says Thank You to djr33 For This Useful Post:
-
thanks for your information
but i got this error
Warning: gregoriantojd() expects exactly 3 parameters, 1 given in
Warning: gregoriantojd() expects exactly 3 parameters, 1 given in
-
-
The first error was a major error-- it didn't know how to start processing the code.
The next one is a specific error to how this code is written.
A function takes a specific number of arguments. For example, echo() takes 1: echo($text).
Others take many more arguments.
It entirely depends on the function.
When a certain number of arguments are expected and NOT sent, or if too many are sent, an error will occur. Just change to the right number of arguments and you will be fine:
instead of func($a), you need func($a,$b,$c).
I have no idea what $b and $c are here, because I don't know what that function is/does. You need to find documentation on it or find where it is defined in your code and then look to see what those values should be.
Daniel -
Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks