Results 1 to 8 of 8

Thread: [RESOLVED] Insert App version info into PHP page to see if upgrade available.

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Resolved [RESOLVED] Insert App version info into PHP page to see if upgrade available.

    My application is almost done. This is what I am looking to do:

    I have an option in Menu Editor which will bring up a page in the format of:
    http://www.mysite.com/CheckUpgrade.php?Version= App.Major & "." & App.Minor & "." & App.Revision

    This is the VB code I am using:
    VB Code:
    1. Private Sub mnuToolsMenuCheckForNewVersion_Click()
    2.     Dim strAppVersion           As String
    3.    
    4.     strAppVersion = App.Major & "." & App.Minor & "." & App.Revision
    5.    
    6.     ShellExecute Me.hWnd, "Open", "http://www.brailleschool.com/CheckUpgrade.php?Version=" & strAppVersion, 0, 0, 3
    7. End Sub
    When the CheckUpgrade.php page comes up, how would I insert their installed app version into the php page?

    I need to show a page (CheckUpgrade.php) that will show two pieces of information.
    1. Their app version number
    2. Current app version number

    How would you go about doing this? I am going to also be using a MySQL backend for the information. MySQL backend also has registration information for all registered users. Please advise if at all possible. Thanks in advance.

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,651

    Re: Insert App version info into PHP page to see if upgrade available.

    You can get the Version parameter that the client app sends from the $_GET superglobal array -

    PHP Code:
    $clientVersionString $_GET['Version']; 
    As for the current version, if that is in the database sure you can retrieve it and then compare it against the client version. You could split the versions and compare each digit. explode() is the equivalent of VB's Split().

    PHP Code:
    // if $currentVersionString is retrieved from the DB and $clientVersion is what we set earlier:

    $clientVersion explode('.'$clientVersionString);
    $currentVersion explode('.'$currentVersionString);

    $majorDiff = (int)$currentVersion[0] - (int)$clientVersion[0];
    $minorDiff = (int)$currentVersion[1] - (int)$clientVersion[1];
    $revisionDiff = (int)$currentVersion[2] - (int)$clientVersion[2]; 
    Do you need assistance with the database coding?
    Last edited by penagate; Apr 11th, 2006 at 08:44 AM.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Insert App version info into PHP page to see if upgrade available.

    Quote Originally Posted by penagate
    Do you need assistance with the database coding?
    What I was looking to do was put the current version into a db structure like so:
    CREATE TABLE `CurrentVersion` (
    `CurrVer` TEXT NOT NULL
    ) TYPE = MYISAM ;
    Then with the PHP page, access the information and print it to the screen with the following, or similar.
    Code:
    <?php
    include("../../config.php");
    
    $connection = mysql_connect("$server", "$db_user", "$db_pass");
    $db = mysql_select_db("$database", $connection);
    $query = "SELECT CurrVer FROM CurrentVersion";
    $result = mysql_query($query, $connection);
    echo "<table width=\"100%\" border=\"1\">";
    echo "<tr>";
    echo "<td><b>Current Version:</b></td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td><b>Installed Version:</b></td></tr>";
    while ($rows = mysql_fetch_array($result))
    {
    echo "<tr><td>$rows[CurrVer]</td></tr>";
    }
    echo "<tr><td>THEIR APP VERSION HERE</td></tr>";
    echo "</table>";
    ?>
    I am not experienced with PHP though

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,651

    Re: Insert App version info into PHP page to see if upgrade available.

    How do you plan to update the current version number?

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Insert App version info into PHP page to see if upgrade available.

    Quote Originally Posted by penagate
    How do you plan to update the current version number?
    manually but if you have a better idea, im up for suggestions.

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,651

    Re: Insert App version info into PHP page to see if upgrade available.

    Not really

    I have fiddled with your code and added the version display lines.

    echo'ing HTML code is a bad idea - just close the PHP tags.
    PHP Code:
    <?php
    include("../../config.php");

    $connection mysql_connect($server$db_user$db_pass);
    mysql_select_db($database$connection);

    $query "SELECT `CurrVer` FROM `CurrentVersion`";

    $clientVersionString $_GET['version'];

    $result = @mysql_query($query$connection);
    if (
    is_resource($result)) {
      
    $currentVersionString mysql_result($result0);
      
    $majorDiff = (int)$currentVersion[0] - (int)$clientVersion[0];
      
    $minorDiff = (int)$currentVersion[1] - (int)$clientVersion[1];
      
    $revisionDiff = (int)$currentVersion[2] - (int)$clientVersion[2];
    }

    ?><table width="100%" border="1">
      <?php if (is_resource($result)): ?>
        <tr>
          <td><b>Current Version:</b> <?=$currentVersionString?></td>
        </tr>
        <tr>
          <td><b>Installed Version:</b> <?=$clientVersionString?></td>
          <td>You are <b><?=$majorDiff?.<?=$minorDiff?>.<?=$revisionDiff?> versions out of date.</td>
        </tr>
      <?php else: ?>
        <tr>
          <td><b>Unable to retrieve the current version</b></td>
        </tr>
      <?php endif; ?>
    </table>
    Last edited by penagate; Apr 11th, 2006 at 09:18 AM.

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Insert App version info into PHP page to see if upgrade available.

    My VB6 code constructs an HTTP address as:
    http://www.brailleschool.com/CheckUpgrade.php?Version=2.0.1
    Your code puts in the version number no problem, the test version in the db is added correctly but the compare part shows incorrectly. Screen shot attached.

  8. #8

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Insert App version info into PHP page to see if upgrade available.

    I updated the code to
    PHP Code:
    <?php 
    include("config.php"); 

    $connection mysql_connect($server$brlqrg_un$brlqrg_pw); 
    mysql_select_db($brlqrf_db$connection); 

    $query "SELECT CurrVer FROM CurrentVersion"

    $clientVersionString $_GET['Version']; 

    $result = @mysql_query($query$connection); 
    if (
    is_resource($result)) { 
      
    $currentVersionString mysql_result($result0); 
      
    $majorDiff $currentVersionString[0] - $clientVersionString[0]; 
      
    $minorDiff $currentVersionString[1] - $clientVersionString[1]; 
      
    $revisionDiff $currentVersionString[2] - $clientVersionString[2]; 


    ?><table> 
      <?php if (is_resource($result)): ?> 
        <tr> 
          <td><b>Current Version:</b></td>
          <td><?=$currentVersionString?></td> 
        </tr> 
        <tr> 
          <td><b>Installed Version:</b></td>
          <td><?=$clientVersionString?></td>
        </tr>
        <tr>
          <td colspan="2">You are <b><?=$majorDiff?>.<?=$minorDiff?>.<?=$revisionDiff?> versions out of date.</td> 
        </tr> 
      <?php else: ?> 
        <tr> 
          <td><b>Unable to retrieve the current version</b></td> 
        </tr> 
      <?php endif; ?> 
    </table>
    And I get the following test output:
    Current Version: 3.0.0
    Installed Version: 2.0.3
    You are 1.0.0 versions out of date

Posting Permissions

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



Click Here to Expand Forum to Full Width