SQL Insert executes twice, php

后端 未结 2 1915
轮回少年
轮回少年 2020-12-12 08:03

Couldn\'t find a straight answer to this. My custom wordpress php code seems to be executed twice when I click on the submit once. When clicked, the codes adds two cities wi

相关标签:
2条回答
  • 2020-12-12 08:35

    Do you see this

    $result = $db->query($query);
    

    And the next line:

    if ($db->query($query) === TRUE) {
    

    This means that you run your query twice. Remove one of the $db->query, e.g.:

    $result = $db->query($query);
    if ($result === TRUE) {    /* do stuff */
    
    0 讨论(0)
  • 2020-12-12 08:47

    you execute the query twice:

    $result = $db->query($query);
    if ($db->query($query) === TRUE) {
    

    should be:

    $result = $db->query($query);
    if ($result === TRUE) {
    
    0 讨论(0)
提交回复
热议问题