mysqli - Website Version PHP -


i trying create version file alert end user if there update.

in theory , practical application:

when admin logs in , goes management interface, script reads remote file , compares remote version local version, if same, report status, if remote greater, alert.

the local version pulled mysql table mysqli , confirmed work, remote file read, confirmed work how ever running issue.

local version 1.3, remote version 1.3 yet reports:

    version - 1.3 out of date, new version 1.3 available download 

when should say

    version date! 

the code using below

    require_once('includes/settings.php');      function check_version() {     global $connection;    $query = "select * version";    $result = mysqli_query($connection, $query);     // if query fails, die , report   if(!$result = $connection->query($query)){     die('there error running query [' . $connection->error .     ']');    }    else {     $row = mysqli_fetch_assoc($result);     $my_version = $row['minor'];     echo '<p>local = '.$my_version.'</p>';      $ctx = stream_context_create(array(             'http' => array(                 'timeout' => 1             )      ));              $rversion = file_get_contents("http://www.twedev.com/projects/microcms/version", 0, $ctx);      echo $rversion;     var_dump($rversion);       if ($my_version === $rversion) {        $dev_msg = '<strong>your micro cms version - '.$my_version.' current</strong>';     }      elseif ($my_version != $rversion) {        $dev_msg = '<strong>your micro cms version - '.$my_version.' out of date,<br> new version '.$rversion.' available download</strong>';     }     else {        $dev_msg = '<strong>something went wrong version server</strong>';     } } return $dev_msg; }  ?> 

what need set of eyes through point me in right direction if possible, has me overly frustrated today.

you using === identical operator compare values, using instead of == compare value , type of value.

the value getting file_get_contents() it's string, , version number seems different string, float number.

update: after using var_dump on both vars see result wasn't same, , solution use trim strip whitespaces end of string.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -