This query runs when I comment out the code above '}else{'. Have done so many like it and way more complex but I can't see where I'm tripping up.
(The page won't run like a syntax mistake. all vars match table)
Thanks. Allen
if ($version == 'prem'){
$sql ="SELECT * FROM artistInfo WHERE user_id = '$user_id' AND artist_name = '$arti开发者_运维知识库st_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' ");
}
}
}
You're missing the closing }
for the while
loop.
missing } for while loop
if($num>0){
while($row = mysql_fetch_array($res)){
$artist_id = $row['artist_id'];
}
}
else {
I think that your last bracket got misplaced. you will also need to move the last }
just before 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' ");
}
}
精彩评论