hey i have this code that always evaluates to true but it should only in the case of there being a value in the database i have selected, maybe im doing this wrong or maybe its something else but i cant seem to figure out the problem :( any assistence is greatly appreciated.
//submission code, inserting data into mysql database
$mySqlDate = date('Y-m-d');
$mySqlTime = date("g:i a");
if(isset($_GET['add']))
{
$newnum = $_GET['newnum'];
$firstname = $_GET['firstname'];
$lastname = $_GET['lastname'];
}
if(strlen($newnum) == $min_length)
{
$newnum = mysqli_real_escape_string($con, $_GET['newnum']);
$firstname = mysqli_real_escape_string($con, $_GET['firstname']);
$lastname = mysqli_real_escape_string($con, $_GET['lastname']);
$check = mysqli_query($con, "SELECT count(*) FROM usernumdata WHERE numb = '".$newnum."'") or die();
$row = mysqli_fetch_row($check);
if ($row[0] > 0)
{
$sql="INSERT INTO usernumdata (numb) VALUES ('".$newnum."')";
if (!mysqli_query($con,$sql)) {
die('Error: ' . mysqli_error($con));
}
echo "<div style='text-align: center'> <font size='6' color='green'>Successfully Added New Number</font> <div>";
}
else
{
echo "<div style='text-align: center'> <font size='6' color='red'>Number Already Exists In Do Not Call List</font> <div>";
}
/*
$sql="INSERT INTO usernumdata (numb, firstname, lastname, date, time) VALUES ('".$newnum."','".$firstname."','".$lastname."','".$mySqlDate."','".$mySqlTime."')";
if (!mysqli_query($con,$sql)) {
die('Error: ' . mysqli_error($con));
}
echo "<div style='position:fixed; bottom:65; left:37%'> <font size='6' color='green'>Successfully Added New Entry</font> <div>";
*/
}
else{
$length = "Remember Phone Number Must be ".$min_length. " Digits Long";
echo "<div style='position:fixed; bottom:50; left:31%;'> <font size='6' color='blue'>".$length."</font> <div>";
}
as you can see from the code above im trying to set it up to do a double test which is probably bad coding pratice but i needs to output different messages in case of either, and what i was trying to do was see if the value was in the database already before inserting a new one but for some reason it always evaluates to true? help