Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
这个php查询应该像其他查询一样运行。Can';我看不出我的错误_Php_Mysql - Fatal编程技术网

这个php查询应该像其他查询一样运行。Can';我看不出我的错误

这个php查询应该像其他查询一样运行。Can';我看不出我的错误,php,mysql,Php,Mysql,当我注释掉上面的代码“}else{”时,这个查询就会运行。我已经做了很多类似的事情,而且更加复杂,但我看不出我在哪里绊倒了 (页面不会像语法错误一样运行。所有变量都匹配表) 谢谢。 艾伦 对于while循环,您缺少结束}。对于while循环,缺少} if($num>0){ while($row = mysql_fetch_array($res)){ $artist_id = $row['artist_id']; }

当我注释掉上面的代码“}else{”时,这个查询就会运行。我已经做了很多类似的事情,而且更加复杂,但我看不出我在哪里绊倒了

(页面不会像语法错误一样运行。所有变量都匹配表)

谢谢。 艾伦


对于
while
循环,您缺少结束
}

对于while循环,缺少}

 if($num>0){
           while($row = mysql_fetch_array($res)){ 
             $artist_id = $row['artist_id'];

        } 
    }
    else {

我想你的最后一个括号放错地方了。您还需要将最后一个
}
移动到
else

if ($version == 'prem'){

    $sql ="SELECT * FROM artistInfo WHERE user_id = '$user_id' AND artist_name = '$artist_name' ";
    $res = mysql_query($sql);
    $num = mysql_num_rows($res);
    if($num>0){
           while($row = mysql_fetch_array($res)){ 
             $artist_id = $row['artist_id'];
            }

    } else {

mysql_query("INSERT INTO artistInfo (user_id, artist_name) VALUES ('$user_id', '$artist_name')");
$row_num = mysql_insert_id();    
$artist_id = $user_id."-".$row_num;      

mysql_query("UPDATE artistInfo SET artist_id = '$artist_id' WHERE row_num = '$row_num'  ");

     }
}

您的
while
循环在
else
上方未关闭。
if ($version == 'prem'){

    $sql ="SELECT * FROM artistInfo WHERE user_id = '$user_id' AND artist_name = '$artist_name' ";
    $res = mysql_query($sql);
    $num = mysql_num_rows($res);
    if($num>0){
           while($row = mysql_fetch_array($res)){ 
             $artist_id = $row['artist_id'];
            }

    } else {

mysql_query("INSERT INTO artistInfo (user_id, artist_name) VALUES ('$user_id', '$artist_name')");
$row_num = mysql_insert_id();    
$artist_id = $user_id."-".$row_num;      

mysql_query("UPDATE artistInfo SET artist_id = '$artist_id' WHERE row_num = '$row_num'  ");

     }
}