Php if else逻辑Block无论怎么运行?

So, Writing this script, and now I do get the correct email, with the old IP address from the database, and the new address from the script. My problem now, is that wether the old ip address and the current are the same or different, the email sends. This script will run every minute to check for dynamic ip address changes, so I don't really want an email every minute. My goal is to have it send the email ONLY if the last posted IP is DIFFERENT from the one discovered. Now, the email is sending wether the IPs are different or not. Everything else works. The email sends fine, and everything else works perfectly. The only problem is using logic to decide when to send the email. (When the new and old IPs are different.)

When the script gets there ip from the database, it looks like 123.123.123.123. The IP from the http://www.ipaddresscheck.comlu.com/ip.php also looks like 123.123.123.123. (***Example) But if the database says 123.123.123.123, and the current is 134.134.134.134, it should send the email.

In the comparison, I've tried !=, ==, and I've tried putting the mail block in the then and else sections. Could the problem be caused by different data types? Is the $new_ip a string while $old_ip is an integer? Im only 14, so... Yea.

 <?php
    //Get IP
    $new_ip = file_get_contents('http://www.ipaddresscheck.comlu.com/ip.php');
    //Connect to SQL
    mysql_connect('localhost','root','root');
    //Select database
    mysql_select_db("ip_changes") or die(mysql_error());
    //Get Date Info
    $date = date("D M Y");
    $time = date("H:i:s");
    //Get last inserted IP
    $sql = mysql_query('SELECT * FROM ip ORDER BY  id DESC LIMIT 1');
    $row = mysql_fetch_array( $sql );
    $old_ip = $row['current_ip'];
    echo $old_ip;
    //Generate SQL query
    $sql="INSERT INTO ip (date, time, current_ip) VALUES ('$date', '$time', '$new_ip')";
    //Execute SQL
    mysql_query($sql);
    //Get latest IP
    //$lastip = mysql_query(SELECT $selected FROM ip ORDER BY id DESC LIMIT 1);

    if ($old_ip == $current_ip)
    {

    }

    else {

    //Set Mail Settings
    $to = "justinmarmorato@gmail.com";
    $subject = "IP Address Change";
    $from = "no-reply@http://mar-remote-net.dns2.us";
    $headers = array (
    "From:" . $from,
    "Content-Type: Text/HTML"
    );
    //Create email
    $finalmessage = <<< EOT
    Hello! This is an automated message from the IPMS. An IP address change has been detected.
    <html>
    <style>
    table, th, td
    {
    border: 2px solid black;
    border-color:grey;
    }
    </style>
    <table class='table'>
    <tr>
    <td>Old IP</td><td>New IP</td><td>Time Detected</td>
    </tr>
    <tr>
    <td>$old_ip</td><td>$new_ip</td><td>$date  $time</td>
    </tr>
    </table>
    </html>
    EOT;
    mail($to,$subject,$finalmessage,  implode("
", $headers));
    mail('justinmarmorato@gmail.com', 'Hello!', implode("
", $headers));


    }
    ?>

Did you mean to say $new_ip instead of $current_ip in your if statement?

$current_ip doesn't appear to be set anywhere -- if that is the case $current_ip will always be unset and will never be equal to $old_ip.