On my site i have this code
| Code: |
<?php
$checkversion = "1.2";
?> |
saved as plusnewscheck.php
and on the script i have made i have this
| Code: |
include("http://scripting4habbo.com/plusnewscheck.php");
if ($checkversion == '$version')
{
echo "<font color='#00FF00'>You currently have the latest version!</font>";
}
else
{
echo "<font color='#FF0000'>You do not have the latest version!</font>";
echo "<br><br>";
echo "<font color='#FF0000'>Your version $version</font>";
echo "<br>";
echo "<font color='#FF0000'>Latest version $checkversion</font>";
} |
but for some reson i keep getting this
You do not have the latest version!
Your version 1.2
Latest version
some reson its not getting the $checkversion from my site.
any reason?
And yes $version does = 1.2
| DanielXP wrote: |
| Code: | // ...
if ($checkversion == '$version')
{
// ...
}
else
{
// ...
} |
|
You are comparing the contents of the variable $checkversion with ... a literal dollar sign, a literal 'v', a literal 'e', ...
Maybe you mean | Code: |
| if ($checkversion == $version) // ... |
no coz i tested it for that
its not getting the var $checkversion
| DanielXP wrote: |
no coz i tested it for that
its not getting the var $checkversion |
| Code: |
<?php
$x = 'one';
$y = 'one';
if ($x == '$y') {
echo 'one is, as expected, equal to one!';
}
else
{
echo 'Uh!????????!?!?!?!?';
}
?> |
Is it me or is that a weird post?
| DanielXP wrote: |
no coz i tested it for that
its not getting the var $checkversion |
Oops ... sorry!
I only now read your post with enough attention to understand it, sorry
If you include a remote file (http://scripting4habbo.com/plusnewscheck.php) it will be interpreted by the server and you will be including an empty file. You have to include it locally instead:
| Code: |
<?php
include ('/path/to/public/files/plusnewscheck.php');
?> |
Changed it 2
include("/home/danielxp/domains/scripting4habbo.com/public_html/plusnewscheck.php");
now i get
You do not have the latest version!
Your version 1.2
Latest version 1.2
but that wont work on other servers coz it need the http:// init
| DanielXP wrote: |
now i get
You do not have the latest version!
Your version 1.2
Latest version 1.2 |
Hmmm ... try this | Code: |
echo "<font color='#FF0000'>You do not have the latest version!</font>";
echo "<br><br>";
echo "<font color='#FF0000'>Your version ", rawurlencode($version), "</font>";
echo "<br>";
echo "<font color='#FF0000'>Latest version ", rawurlencode($checkversion), "</font>"; |
| DanielXP wrote: |
| but that wont work on other servers coz it need the http:// init |
Can you change that to a mailing list or web forum or something instead of phoning home for every page request?
| Quote: |
Your version 1.2
Latest version 1.2 |
Hmmm ... try this | Code: |
echo "<font color='#FF0000'>You do not have the latest version!</font>";
echo "<br><br>";
echo "<font color='#FF0000'>Your version ", rawurlencode($version), "</font>";
echo "<br>";
echo "<font color='#FF0000'>Latest version ", rawurlencode($checkversion), "</font>"; |
[/quote]
But that all works fine its just the if init
| DanielXP wrote: |
| But that all works fine its just the if init |
So, you still want to phone home with every request; save this as plusnewscheck.php (not tested) | Code: |
<?php
echo '<?php $checkversion = "1.2"; ?>';
?> |
You do not have the latest version!
Your version 1.2
Latest version
with change that
| DanielXP wrote: |
You do not have the latest version!
Your version 1.2
Latest version
with change that |
OK, if you include the file with http://, you have to do this:
| Code: |
<?php
echo '<?php $checkversion = "1.2"; ?>';
?> |
If you do it without the http://, you have to do this:
| Code: |
<?php
$checkversion = "1.2";
?> |
You should not mix them!
After that your code will display:
| Quote: |
You do not have the latest version!
Your version 1.2
Latest version 1.2 |
As hexkid already said, you should change this:
| Code: |
| if ($checkversion == '$version') |
to this:
| Code: |
| if ($checkversion == $version) |
Using single quotes means you want the literal value, so you are comparing 1.2 against $version, not the content of variable $version, but just dollar sign version.
However using double quotes means you want variables replaced. So you could do:
| Code: |
| if ("$checkversion" == "$version") |
But that wouldn't make any sense, as those quotes are there for no reason at all, and increase the parse time.
| Code: |
<?php
// phone home to get the $latest_version
include 'http://www.example.com/latest_version.php';
if ($latest_version > '0.4.8') {
echo 'Current version of this script is oudated.<br>';
echo 'You need to update it.<br>';
exit(0);
}
// ...
?> |
Hmmm ... what makes me trust the owner of example.com to not change "latest_version.php" to something like | Code: |
<?php
echo '<?php $latest_version = "0.4.8"; ?>';
// I'm sure you have better imagination than me
@mail('president@whitehouse.gov', 'Hi!', 'bye');
?> |
Cheers u guys
You currently have the latest version!