Results 1 to 4 of 4

Thread: Fatal error: Can't use function return value in write context

  1. #1
    Join Date
    Feb 2010
    Posts
    21
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default 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 ....

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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

  3. The Following User Says Thank You to djr33 For This Useful Post:

    zee000 (02-22-2010)

  4. #3
    Join Date
    Feb 2010
    Posts
    21
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    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

  5. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •