Delete album and items related to the album HELP

here’s the problem i am trying to delete an album within the album should also delete the photos related to that album this what i tried gives this error
Delete image failed. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 3
my tables are
table albums fields album_id, album_name, album_owner, sub_album
table photos fields, photo_id, photo_name, photo_extension, photo_proper photo_owner, photo_date, photo_comments, photo_size, album_id

photo_proper is the name image stored in folder

try one gives echos the else statment at the end (Cannot delete a non-existent album.)

<?php
define('ROOT_DIR', './');
define('PROPER', TRUE);
/**
* include common files
*/
include_once(ROOT_DIR. 'includes/common.inc.php');


// No album id has been selected
if (isset($_GET['albums'])) 
 {
   // get the image file name so we
   // can delete it from the server
   $sql = "SELECT album_id, album_name, album_owner, sub_album

           FROM albums

           WHERE album_id = {$_GET['albums']}";

   $result = mysql_query($sql);

             

   if (mysql_num_rows($result) == 1) {

      $row = mysql_fetch_assoc($result);

      // get the image filenames first so we can delete them
      // from the server
     $sql = "SELECT photo_id, photo_proper

           FROM photos

           WHERE photo_id = {$_GET['albums']}";

   $result = mysql_query($sql);


   if (mysql_num_rows($result) == 1) {

      $row = mysql_fetch_assoc($result);
      
define("GALLERY_IMG_DIR", "./photos/");

      // remove the image and the thumbnail from the server
      unlink(GALLERY_IMG_DIR . $row['photo_proper']);

      unlink(GALLERY_IMG_DIR . 'thumbs/' . $row['photo_proper']);
      
      // and then remove the database entry

      $sql = "DELETE FROM photos

              WHERE photo_id = {$_GET['photos']}";
      $result = mysql_query("DELETE FROM albums
                             WHERE album_id = $album_id")
                or die('Delete album failed. ' . mysql_error());

      // album deleted successfully, let the user know about it
      echo "<p align=center>Album '$album_name' deleted.</p>";
   } else {
      echo "<p align=center>Cannot delete a non-existent album.</p>";
   }

}
}

?>

i do not think so ok i gt to wrk only one problem it has conflict with another line page script
this how is looking now it deletes but now gives this notice

<?php

   error_reporting(E_ALL); 
   ini_set("display_errors", 1); 

   define('ROOT_DIR', './');
   define('PROPER', TRUE);
   define("GALLERY_IMG_DIR", "./photos/");

/**
* include common files
*/
include_once(ROOT_DIR. 'includes/common.inc.php');


// No album id has been selected
if (isset($_GET['albums'])) 
 {
   // get the image file name so we
   // can delete it from the server
   $sql = "SELECT album_id, album_name, album_owner, sub_album
            FROM albums
            WHERE album_id = {$_GET['albums']}";

   $result = mysql_query($sql) or die('Album Selection failed. ' . mysql_error());

   if (mysql_num_rows($result) == 1) {

      $row = mysql_fetch_assoc($result);

      // get the image filenames first so we can delete them
      // from the server
      $psql = "SELECT photo_id, photo_proper
              FROM photos
              WHERE album_id = {$row['album_id']}";

      $presult = mysql_query($psql) or die('Photo Selection failed. ' . mysql_error());

      while ($prow = mysql_fetch_assoc($presult)) {
         // remove the image and the thumbnail from the server
         unlink(GALLERY_IMG_DIR . $prow['photo_proper']);
         unlink(GALLERY_IMG_DIR . 'thumbs/' . $prow['photo_proper']);
      } 
           
      // and Now we remove the database entries 

      $sql = "DELETE FROM photos
               WHERE album_id = {$row['album_id']}";
      mysql_query($sql) or die('Delete of Album associated photos failed. ' . mysql_error());               

      $sql =  "DELETE FROM albums
                    WHERE album_id = {$row['album_id']}";              
      mysql_query($sql) or die('Delete album failed. ' . mysql_error());

      // album deleted successfully, let the user know about it
      echo "<p align=center>Album {$row['album_name']} deleted.</p>";

     
   } else {
      echo "<p align=center>Cannot delete a non-existent album.</p>";
   }

}

Notice: Use of undefined constant THIS_SCRIPT - assumed ‘THIS_SCRIPT’ in C:\xampp\htdocs\rookierods\includes\common.inc.php on line 154
now this is the comon.in.php page the error seems to be oon this line
if (in_array(THIS_SCRIPT, $access_pages)) any idea why??

<?php
/**
* check for hacking attempt
*/
if (!defined("PROPER"))
{
    die("hacking attempt");
}

/**
* deal with backwards compatibility
*/
if (!isset($_SERVER))
{
    $_GET = &$HTTP_GET_VARS;
    $_POST = &$HTTP_POST_VARS;
    $_SERVER = &$HTTP_SERVER_VARS;
    $_COOKIE = &$HTTP_COOKIE_VARS;
    $_SESSION = &$HTTP_SESSION_VARS;
}

/**
* what globals are allowed
*/
$allowed_globals = array(

    'GLOBALS',
    '_POST',
    '_GET',
    '_FILES',
    '_REQUEST',
    '_SERVER',
    '_COOKIE',
    '_SESSION',
    'allowed_globals'

);

/**
* check any globals that are passed
* and unset if not allowed
*/
foreach ($GLOBALS as $key => $value)
{
    if (!in_array($key, $allowed_globals) && $key != 'key' && $key != 'value')
    {
        unset($GLOBALS[$key]);
    }
}

/**
* deal with magic quotes (stripslashes)
*/
if (get_magic_quotes_gpc())
{
    function strip_quotes (&$vars) 
    { 
        if (is_array($vars)) 
        {
            foreach ($vars AS $key => $value) 
            { 
                if (is_string($value)) 
                { 
                    $vars[$key] = stripslashes($value); 
                } 
                elseif (is_array($value))
                { 
                    $vars[$key] = strip_quotes($value); 
                } 
            } 
        } 

        return $vars; 
    } 

    $_GET = strip_quotes($_GET);
    $_POST = strip_quotes($_POST);
    $_COOKIE = strip_quotes($_COOKIE);
}

include_once(ROOT_DIR. "classes/template.class.php");
include_once(ROOT_DIR. "classes/error.class.php");
include_once(ROOT_DIR. "classes/database.class.php");
include_once(ROOT_DIR. "classes/sessions.class.php");
include_once(ROOT_DIR. "includes/constants.inc.php");

/**
* setup the database connection
*/
$db_name = 'eurico_edy';
$db_pass = '';
$db_user = 'root';
$db_host = 'localhost';

if (!$db = new db_handler($db_user, $db_pass, $db_name, $db_host))
{
    die("COULD NOT CONNECT TO DATABASE");
}

/**
* setup style
*/
if (!$template = new template(ROOT_DIR))
{
    die("COULD NOT INITIALISE TEMPLATE ENGINE");
}

/**
* begin error handling
*/
if (!$errors = new error_handler())
{
    die("COULD NOT INITIALISE ERROR HANDLER");
}

$sessions = new session_handler();

/**
* get the mode
*/
if (isset($_REQUEST['mode']))
{
    $mode = trim($_REQUEST['mode']);
}
else
{
    $mode = '';
}

/**
* what page are we on?
*/
if (isset($_REQUEST['page']))
{
    $page = intval($_GET['page']) - 1;
}
else
{
    $page = 0;
}

/**
* for certain pages we need to check admin access
*/
$access_pages = array(

    'drivers',
    'news',
    'newsletter',
    'admin'

);

if (in_array(THIS_SCRIPT, $access_pages))
{
    if ($mode == "new" || THIS_SCRIPT == 'newsletter' || THIS_SCRIPT == 'admin')
    {
        // start a session
        session_start();

        if (!isset($_SESSION['logged_in']))
        {
            header("location:" .ROOT_DIR. "login.php");
            exit();
        }
    }
}
?>

are these innodb tables? if so, you should be using ON DELETE CASCADE

Problem solved thanks to evryone