Jump to content

[SOLVED] WEIRD curley bracket mismatch problem


hatrickpatrick

Recommended Posts

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...)

Link to comment
Share on other sites

<?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.

Link to comment
Share on other sites

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
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.