sql >> Database >  >> RDS >> Mysql

Gegevens invoegen als het aantal rijen groter is dan 0 werkt niet

function storeLink($url,$gathered_from) {

    global $conn;   
    $querycheck = "SELECT COUNT(*) as CNT FROM test WHERE link = '$url'";
    $resultcheck = mysqli_query($conn, $querycheck);
    $row = mysqli_fetch_array($resultcheck, MYSQLI_ASSOC);

    if($row['CNT'] < 1) {
       echo "<font color='red'>".$row['CNT']."</font>";
       $url = mysqli_real_escape_string($conn,$url);
       $gathered_from = mysqli_real_escape_string($conn,$gathered_from);
       $query = "INSERT INTO test (link, source) VALUES ('$url', '$gathered_from')";
       mysqli_query($conn,$query) or die('Error, insert query failed');
    }
}

OF

function storeLink($url,$gathered_from) {

    global $conn;   
    $querycheck = "SELECT link FROM test WHERE link = '$url'";
    $resultcheck = mysqli_query($conn, $querycheck);
    $row = mysqli_fetch_array($resultcheck, MYSQLI_ASSOC);

    if(mysqli_num_rows($resultcheck)==0) {
       echo "<font color='red'>".mysqli_num_rows($resultcheck)."</font>";
       $url = mysqli_real_escape_string($conn,$url);
       $gathered_from = mysqli_real_escape_string($conn,$gathered_from);
       $query = "INSERT INTO test (link, source) VALUES ('$url', '$gathered_from')";
       mysqli_query($conn,$query) or die('Error, insert query failed');
    }
}


  1. PHP converteert datetime naar seconden

  2. Hoe zie ik de verschillen tussen 2 MySQL-dumps?

  3. Lijst met tabellen in een PostgreSQL-schema

  4. onbekende database in jdbc