2
    <?php

$vc=$_POST['versioncode'];

if ($vc == 1.0.2){

echo 1;  // for correct version code

} else {

echo 0; // for incorrect version code

}
?>

I get this error. Parse error: syntax error, unexpected T_DNUMBER in /hermes/bosweb26b/b865/ipg.synamegamescom/giveaway/versioncheck.php on line 5

4 Answers 4

4

You need to quote 1.0.2 as it is not a valid number (T_DNUMBER):

if ($vc == '1.0.2') {
  ...
}

I'd also encourage you to look at version_compare()

Sign up to request clarification or add additional context in comments.

Comments

3

if ($vc == 1.0.2){

1.0.2 is not a valid number. Probably you need to compare it as a string '1.0.2' like:

if ($vc == '1.0.2'){

Comments

2

You should use: if ($vc == "1.0.2") { ... }

2 Comments

I think you mean if ($vc == "1.0.2")... ?
yes, bad edit of mine, thanks. I added the brackets later and carried the " along.
0

1.0.2 is not a valid number. You should treat it as a string instead:

if ($vc == '1.0.2') {...}

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.