if ($result = mysqli_query($db, "SELECT alias FROM env8g_content WHERE alias !== $page_alias")) { $query = "INSERT INTO env8g_content (title,alias,introtext,state,sectionid,catid,created,created_by,publish_up) values ($page_title,$page_alias,$page_edit,'1','0','9',$page_date,'982',$page_date)"; mysqli_query($db, $query); } 

Why does not work, the data is correct.

    1 answer 1

     WHERE alias !== $page_alias 

    replace with

     WHERE alias != $page_alias 

    But in general it is not entirely clear what you want to get the first request?

    if a match then the condition should be like this

     if (!($result = mysqli_query($db, "SELECT alias FROM env8g_content WHERE alias = $page_alias"))) { $query = "INSERT INTO env8g_content (title,alias,introtext,state,sectionid,catid,created,created_by,publish_up) values ($page_title,$page_alias,$page_edit,'1','0','9',$page_date,'982',$page_date)"; mysqli_query($db, $query); } 

    in general, put a unique index on the alias field, and MySQL itself will check for the uniqueness of the field, and if you throw an error, you only need to process it

    By the way, an insertion with an IGNORE directive or ON DUPLICATE KEY UPDATE will help you, depending on the application logic. Look here

    • The first query should look for matches, if it did not find it, then execute the function - Happy_Cougar