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');
}
}
ELLER
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');
}
}