FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Latest version checker





DanielXP
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?
DanielXP
And yes $version does = 1.2
hexkid
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) // ...
DanielXP
no coz i tested it for that

its not getting the var $checkversion
hexkid
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!????????!?!?!?!?';
}
?>
DanielXP
Is it me or is that a weird post?
hexkid
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 Smile

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');
?>
DanielXP
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
hexkid
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?
DanielXP
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
hexkid
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"; ?>';
?>
DanielXP
You do not have the latest version!

Your version 1.2
Latest version

with change that
Stubru Freak
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.
hexkid
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');
?>
DanielXP
Cheers u guys

You currently have the latest version!
Related topics
Macromedia updates Web conferencing tools
Arles Image Web Page Creator, creating the best images site
More forum types.
Major Solaris features slip to 2006
Win xp or win 98 ( donnow about latest version)
Latest version of girlfriend...
The latest version of girlfriend 4.0 Beta
Which version of php?
english threat
Too many crashes with the latest version of Firefox
Review Skype new version and how to record Skype video call
Which php version on the new server? (5.2.12 or 5.3.1)
Latest Android version
Indie Browser MMORPG Game MonsterMMORPG - My Game
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.