Else will not execute is at first sight? Solution Solutions

Source: Internet
Author: User
Else will not execute is at first sight?
if ($_post["submit"]) {
$id =$_post["ITM"];
$ip =$_server["REMOTE_ADDR"];
$postdate = Date (' y-m-d h:i:s ', Time ());
$sql = "Select IP from Ipadd where ip= ' $ip '";
$result =mysql_query ($sql);
$row =mysql_fetch_array ($result);

if (mysql_num_rows ($row) < 1) {
$sql = "INSERT into Ipadd (Ip,id, postdate) VALUES (' $ip ', ' $id ', ' $postdate ')";
$res = mysql_query ($sql);

}
else{
echo "Not Empty";
}
}

?>


This will only perform the if first half, the echo "not empty" behind, and this will not be done, help to see what the problem is.
------to solve the idea----------------------
if (mysql_num_rows ($row) < 1) {

Switch

if (mysql_num_rows ($ result) < 1) {
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.