Page 1 of 1

Problem with deleting from database

Posted: Sun Aug 06, 2006 2:13 am
by tail
I'm using the code to delete records from a MySQL database:

Code: Select all

<?
$id=$_GET['id'];
if ($id=="") {
	die("No Layout Specified");
}
$username="perks";
$pass="*****-";
$database="perks_layouts";
$pass2=$_POST["pass2"];
mysql_connect(localhost,$username,$pass);
@mysql_select_db($database) or die("Unable to select database");

if($pass2=="asf") {
			$query="DELETE FROM `layouts` WHERE `id` = `$id`";
			mysql_query($query);
			$result=mysql_query($query);
			$num=mysql_numrows($result);

			$i=0;
			while ($i < $num) {
			$code=mysql_result($result,$i,"code");
			$image=mysql_result($result,$i,"image");
			$date=mysql_result($result,$i,"date");
			$name=mysql_result($result,$i,"name");
			echo "Layout was deleted successfully!";
			echo "<br><a href='index.php'>Back</a>";
			mysql_close();
			++$i;
}
if ($pass2 != "") {
	if ($pass2 != "asf") {
			echo "Incorrect Password";
	}
}

echo "<br><form action='delete.php?id=$id' method='post'>";
echo "Password: <input type='password' name='pass2'><br>";
echo "<input type='submit' value='Delete'>";
echo "</form>";
?>
But I get this error:

Parse error: syntax error, unexpected $end in /home3/perks/public_html/delete.php on line 47

What I don't understand is that there is no $end in the whole document. Can someone please help me?

Posted: Sun Aug 06, 2006 2:56 am
by Nodda4me
I believe you are missing the ending '}' for:

Code: Select all

while ($i < $num) {

It should be:

Code: Select all

while ($i < $num) {
                          $code=mysql_result($result,$i,"code");
                          $image=mysql_result($result,$i,"image");
                          $date=mysql_result($result,$i,"date");
                          $name=mysql_result($result,$i,"name");
                          echo "Layout was deleted successfully!";
                          echo "<br><a href='index.php'>Back</a>";
                          ++$i; 
                        }
                        mysql_close();

Posted: Sun Aug 06, 2006 2:57 am
by tail
Hey Josh, yeah I just told you that on AIM.