S
S
santavits2018-03-21 07:24:24
PHP
santavits, 2018-03-21 07:24:24

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 "Занесли пост в базу";
}

The conditions are as follows
By the $ret value, we get a selection from the database, with all the lines where the text needs to be checked And
so the condition itself
If the text contains http, then we make an entry in the database with the text "Advertising post, skip" Is there a text in the database that
we want to add now ? , skip" If not that, not that, then we add the text that we have in the value of $x, i.e. the second condition, it simply skips.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Sinitsyn, 2018-03-21
@a_u_sinitsin

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)

K
kot2566, 2018-03-21
@kot2566

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

E
Evgeny Vorobyov, 2018-04-06
@lokki00003

elseif is spelled together

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question