PHP似乎在false if中执行特定的一行代码


PHP seems to execute one particular line of code in a false if

我希望这里有人可以帮助我,因为我被我的PHP代码中的这个奇怪的错误难住了。首先,下面是代码的相关部分:

//STEP 1b - PREPROCESSING OF SUBMITTED FORM DATA (table level)
while($count_table++ != $num_tables && $submit != ""){
$table_show[$count_table] = mysql_escape_string($_POST[table_show_.$count_table]);
$ne_page[$count_table] = mysql_escape_string($_POST[ne_page_.$count_table]);
}
//STEP 2 - SUBMITTED?
if($submit!=""){
//The form has been submitted
//STEP 3 - VALIDATION
    //Reset counts
    $count_column = 0;
    $count_table = 0;
    //Check for empty fields
    while($count_table++ != $num_tables){ if($table_show[$count_table] != ""){ //While there are tables, validate only if they are in included in NexEdit

在我测试的场景中,这是if返回假值的地方。因此,它应该直接返回到它前面的while语句(我在后面的同一点关闭while和if)。

        if($ne_page[$count_table] == ""){
                $error = "You forgot to give a NexEdit name to one or more of the tables you want to include in NexEdit.";
        }
        echo "Debug";

正如预期的那样,它永远不会回显,因为PHP从一开始就没有在前面输入if。

                    while($db_field[++$count_column]){ //Stay inside the loop until we run out of db fields
            if($db_field[$count_column] == "" || $db_type[$count_column] == "" || $db_table[$count_column] == "" || $ne_name[$count_column] == "" || $ne_type[$count_column] == "" || $ne_order[$count_column] == ""){ //Check if all information is entered if the column is selected to be included in NexEdit
                $error = "You didn't enter all required information. Required fields are indicated with (*).";

这就是错误发生的地方:即使PHP不应该在前面输入if(如调试回显所示),它仍然在这里设置$error的值。

            }
        }
    }}
//More code...

我错过了什么?我已经看了几个小时这个,甚至问一个朋友的帮助开发,但我就是找不到我做错了什么。


所有代码在一个块中:

//STEP 1b - PREPROCESSING OF SUBMITTED FORM DATA (table level)
while($count_table++ != $num_tables && $submit != ""){
$table_show[$count_table] = mysql_escape_string($_POST[table_show_.$count_table]);
$ne_page[$count_table] = mysql_escape_string($_POST[ne_page_.$count_table]);
}
//STEP 2 - SUBMITTED?
if($submit!=""){
//The form has been submitted
//STEP 3 - VALIDATION
    //Reset counts
    $count_column = 0;
    $count_table = 0;
    //Check for empty fields
    while($count_table++ != $num_tables){ if($table_show[$count_table] != ""){ //While there are tables, validate only if they are in included in NexEdit
        if($ne_page[$count_table] == ""){
                $error = "You forgot to give a NexEdit name to one or more of the tables you want to include in NexEdit.";
        }
        echo "Debug";
                    while($db_field[++$count_column]){ //Stay inside the loop until we run out of db fields
            if($db_field[$count_column] == "" || $db_type[$count_column] == "" || $db_table[$count_column] == "" || $ne_name[$count_column] == "" || $ne_type[$count_column] == "" || $ne_order[$count_column] == ""){ //Check if all information is entered if the column is selected to be included in NexEdit
                $error = "You didn't enter all required information. Required fields are indicated with (*).";
            }
        }
    }}
//More code...

我首先想到的是一个不匹配的大括号。

你说"它应该直接回到它前面的while"。除非我弄错了,看起来while循环在if语句之前关闭。

是否可以发布更完整/未切碎的方法版本?它可能有助于诊断

while循环期间,$error的值永远不会被清除。所以,你认为它被填充的地方实际上是while循环的前一次迭代的结果。