Answer the question
In order to leave comments, you need to log in
Why else if condition doesn't work?
Why the else if conditions don't work
Here is the code itself
$x = "мой текст";
$search="http";
$dub = mysql_query("SELECT (text) FROM `biznes` WHERE 1", $db);
$ret = mysql_fetch_array($dub);
if (strstr($x, $search)) {
echo "Рекламный пост, пропускаем";
mysql_query("INSERT INTO `biznes`(reklama) VALUES ('1')");
}else if ($ret == $x){
mysql_query("INSERT INTO `biznes`(reklama) VALUES ('1')");
}else{
mysql_query("INSERT INTO `biznes`(foto,text) VALUES ('/images/$imge','$x')");
echo "Занесли пост в базу";
}
Answer the question
In order to leave comments, you need to log in
Why not just make the column unique? Why produce empty records in the table, if you can put 1 in the reklama field of a single message in case of an error adding a double ... or increase by 1 - then there will be a spam counter)
More or less like this:
$sql =mysql_query ("SELECT 'text' FROM 'biznes' WHERE 'text'='text')";
if(mysql_num_rows($sql) < 0)
{
mysql_query("INSERT INTO `biznes`(foto,text) VALUES ('/images/$imge','$x')");
}else {
mysql_query("INSERT INTO `biznes`(reklama) VALUES ('1')");
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question