hatrickpatrick Posted August 13, 2007 Share Posted August 13, 2007 This is REALLY bizarre... I'm making an album editor for a guitar patch site, and I have a section for editing the name and order of a song. Bizarrely, if I put in the closing curley bracket to the $edit section, I get an "unexpected }" error, but if I leave it out, the syntax checker tells me the script is fine, even though it has one more { than }...? if ($edit) { $sqledit="SELECT * FROM songs WHERE song_id=$edit"; $edresult=mysql_query($sqledit); $editrow=mysql_fetch_assoc($edresult); $sqleditsa="SELECT * FROM albums WHERE album_id=$editrow[song_album]"; $resulteditsa=mysql_query($sqleditsa); $rowedsa=mysql_fetch_assoc($resulteditsa); ?> <table> <form action=editsongs.php?editsong=<?=$edit ?>> <tr class="dark"> <th style="width: 55%">Song Name</th> <th>Album</th> <th>Order</th> </tr> <tr> <td><input type=text name="edname" value=<?=$editrow["song_name"] ?>></td><td> <select name="editsa_id"> <option selected=selected>Select an album...</option> <? $sqlalist="SELECT * FROM albums ORDER BY album_id ASC"; $resultalist=mysql_query($sql); while ($rowalist=mysql_fetch_assoc($result)) { if ($roweditsa["album"]==$rowalist["album_id"]) { $selecteda='selected = 1'; } elseif (!$roweditsa["album"]==$rowalist["album_id"]) { $selecteda=""; } ?> <option value="<?=$rowalist["album_id"] ?>" <?=$selecteda ?>><?=$row["album_name"] ?></option></td> <? } ?> </td><td><input type=text name=edits_order value=<?=$editrow["order"] ?></td></tr><tr><td><input type=submit name=editsub value=Submit></form> <? } ?> That's the code WITH the extra curley bracket in. The last one there before the final ?> gives an unexpected parse error. And it's definetely a problem in that section of the file, because I tried making a file with just that code in it and got the same results Anyone know how to fix that? (BTW, I know my code is terrible, this is literally the first draft of the file...) Quote Link to comment https://forums.phpfreaks.com/topic/64637-solved-weird-curley-bracket-mismatch-problem/ Share on other sites More sharing options...
NArc0t1c Posted August 13, 2007 Share Posted August 13, 2007 <?php if ($edit) { $sqledit="SELECT * FROM songs WHERE song_id=$edit"; $edresult=mysql_query($sqledit); $editrow=mysql_fetch_assoc($edresult); $editrow_song_album = $editrow['song_album']; $sqleditsa="SELECT * FROM albums WHERE album_id='$editrow_song_album'"; $resulteditsa=mysql_query($sqleditsa); $rowedsa=mysql_fetch_assoc($resulteditsa); ?> <table> <form action="editsongs.php?editsong=<?=$edit ?>"> <tr class="dark"> <th style="width: 55%">Song Name</th> <th>Album</th> <th>Order</th> </tr> <tr> <td><input type="text" name="edname" value="<?=$editrow["song_name"] ?>"></td><td> <select name="editsa_id"> <option selected="selected">Select an album...</option> <?php $sqlalist="SELECT * FROM albums ORDER BY album_id ASC"; $resultalist=mysql_query($sql); while ($rowalist=mysql_fetch_assoc($result)) { if ($roweditsa['album'] == $rowalist['album_id']) { $selecteda = 'selected="selected"'; } elseif ($roweditsa['album'] != $rowalist['album_id']) { $selecteda = ''; } ?> <option value="<?=$rowalist['album_id'] ?>" <?=$selecteda ?>><?=$row['album_name'] ?></option></td> <?php } ?> </td><td><input type="text" name="edits_order" value="<?=$editrow['order'] ?>"></td></tr><tr><td><input type="submit" name="editsub" value="Submit"></form> <?php } ?> Not any open brackets That I can see. Quote Link to comment https://forums.phpfreaks.com/topic/64637-solved-weird-curley-bracket-mismatch-problem/#findComment-322250 Share on other sites More sharing options...
MadTechie Posted August 13, 2007 Share Posted August 13, 2007 try <?php if ($edit) { $sqledit="SELECT * FROM songs WHERE song_id=$edit"; $edresult=mysql_query($sqledit); $editrow=mysql_fetch_assoc($edresult); $editrow_song_album = $editrow['song_album']; $sqleditsa="SELECT * FROM albums WHERE album_id='$editrow_song_album'"; $resulteditsa=mysql_query($sqleditsa); $rowedsa=mysql_fetch_assoc($resulteditsa); ?> <table> <form action=editsongs.php?editsong=<? echo $edit ?>> <tr class="dark"> <th style="width: 55%">Song Name</th> <th>Album</th> <th>Order</th> </tr> <tr> <td><input type=text name="edname" value=<?php echo $editrow["song_name"] ?>></td><td> <select name="editsa_id"> <option selected=selected>Select an album...</option> <?php $sqlalist="SELECT * FROM albums ORDER BY album_id ASC"; $resultalist=mysql_query($sql); while ($rowalist=mysql_fetch_assoc($result)) { if ($roweditsa['album'] == $rowalist['album_id']) { $selecteda = 'selected="selected"'; } elseif ($roweditsa['album'] != $rowalist['album_id']) { $selecteda = ""; } ?> <option value="<?php echo $rowalist['album_id'] ?>" <?php echo $selecteda ?>><?php echo $row['album_name'] ?></option></td> <?php } // close while ?> </td><td><input type="text" name="edits_order" value="<?php echo $editrow['order'] ?>"></td></tr><tr><td><input type="submit" name="editsub" value="Submit"></form> <?php } // close IF ?> Quote Link to comment https://forums.phpfreaks.com/topic/64637-solved-weird-curley-bracket-mismatch-problem/#findComment-322254 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.