当我将'} else {'上面的代码注释掉时,此查询就会运行。做过这么多喜欢它的方式和方式更复杂,但我看不出我在绊倒的地方。
(页面不会像语法错误一样运行。所有vars匹配表)
感谢。 阿伦
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' ");
}
}
}
答案 0 :(得分:1)
您错过了}
循环的结束while
。
答案 1 :(得分:1)
缺少} for while循环
if($num>0){
while($row = mysql_fetch_array($res)){
$artist_id = $row['artist_id'];
}
}
else {
答案 2 :(得分:0)
我认为你的最后一个支架错位了。您还需要在}
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' ");
}
}