1

I', trying to update a row on parse using PHP. I'm using this function:

    if (isset($_GET['updateHistory']))
    {
        updateHistory($_GET['updateHistory']);
    }

    if (isset($_GET['yesNo']))
    {
        yesNo($_GET['yesNo']);
    }

function updateHistory($obId,$yesNo) {

        $bool = "";
        if ($yesNo == "YES") {
            $bool = true;
        } else {
            $bool = false;
        }

        $query = new ParseQuery("TestObject");
        try {
            $history = $query->get($obId);
            $history->set("isHistory", $bool);

            $history->save();
        } catch (ParseException $ex) {
             echo "Error Updating History";
        }
    reload();
}

The problem now is I can't pass the 2nd variable which is $yesNo using

<a href='?updateHistory=$obId&yesNo=YES'>YES</a>

How can I pass the 2nd variable? thanks!

1
  • you're function yesNo doesn't exist, you need to pass your $_GET['yesNo'] in the updateHistory instead a new function yesNo Commented Dec 10, 2015 at 8:47

2 Answers 2

2

try

if (isset($_GET['updateHistory'], $_GET['yesNo'])) {
    // you should sanitize your $_GET values before using them
    updateHistory($_GET['updateHistory'], $_GET['yesNo']);
}
Sign up to request clarification or add additional context in comments.

Comments

1

Since your function depends on both variables being set, combine the if-statement to check both fields and do a single call to your function:

if (isset($_GET['updateHistory']) && isset($_GET['yesNo'])) {
    updateHistory($_GET['updateHistory'], $_GET['yesNo']);
}

You can then drop this part altogether:

if (isset($_GET['yesNo']))
{
    yesNo($_GET['yesNo']);
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.