I have been trying to solve this issue for 5 days please help

I am REALLY REALLY sorry about posting about an error, but I have been trying to fix it myself without any success. I keep getting this error “Fatal error: Cannot redeclare album_data() in /home/rankontk/public_html/func/album.func.php on line 3” Any help will be greatly appreciated.

album.func.php

<?php function album_data($album_id){ $album_id = (int)$album_id; $args = func_get_args(); unset($args[0]); $fields = '`'.implode('`, `', $args).'`'; $query = mysql_query("SELECT $fields FROM `albums` WHERE `album_id`=$album_id AND `user_id`=".$_SESSION['user_id']); $query_result = mysql_fetch_assoc($query); foreach($args as $field){ $args[$field] = $query_result[$field]; } return $args; } function album_check($album_id){ } function get_albums(){ $albums = array(); $albums_query = mysql_query(" SELECT `albums`.`album_id`, `album`.`timestamp`, `albums`.`name`, LEFT(`albums`.`description`, 50) as `description`, COUNT(`images`.`image_id`) as `image_count` FROM `albums` LEFT JOIN `images` ON `albums`.`album_id` = `images`.`album_id` WHERE `albums`.`user_id` = ".$_SESSION['user_id']." GROUP BY `albums`.`album_id`"); while($albums_row = mysql_fetch_assoc($albums_query)){ $albums[] = array('id' => $albums_row['album_id'], 'timestamp' => $albums_row['timestamp'], 'name' => $albums_row['name'], 'description' => $albums_row ['description'], 'count' => $albums_row['image_count']); } return $albums; } function create_album($album_name, $album_description){ $album_name = mysql_real_escape_string(htmlentities($album_name)); $album_description = mysql_real_escape_string(htmlentities($album_description)); mysql_query("INSERT INTO `albums` VALUES ('', '".$_SESSION['user_id']."', UNIX_TIMESTAMP(), '$album_name', '$album_description')"); mkdir('upload/'.mysql_insert_id(), 0744); mkdir('upload/thumbs'.mysql_insert_id(), 0744); } function edit_album($album_id, $album_name, $album_description){ $album_id = (int)$album_id; $album_name = mysql_real_escape_string($album_name); $album_description = mysql_real_escape_string($album_description); mysql_query("UPDATE `albums` SET `name`='$album_name', `description`='album_description' WHERE `album_id`=$album_id AND `user_id`=".$_SESSION['user_id']); } function delete_album($album_id){ } ?>

I do not see anything that would cause this error in this code what I am thinking is that in the rest of the code that you are not showing here, there is probably some “includes” and you might be including the same page twice. take a look and let me know if I am right?

If not is there another page in which you are including that also has this same function being declared?

I am not sure if I understand what your code does. This may be the problem, but, if this is all of the code, it does not make sense to me… I understand that you are trying to load the album data using the album_id as an index, but, args in a function are local… This is what I see:

function album_data($album_id){ **** Declares a function with one arg, $album_id

$album_id = (int)$album_id;            **** Useless command, does nothing...  A query uses strings not int's
  
$args = func_get_args();                 **** Get the args, you already have it $album_id...  Does nothing...

unset($args[0]);                              **** Sets the args, in this case $album_id to NULL  ???  why?

$fields = '`'.implode('`, `', $args).'`'; **** Takes the NULL and puts it into $fields???

Then, calls a QUERY with $fields = NULL… I don’t even see what this function does and it is not called in your code. In your function GetAlbums, you already get all the data, so why have this function at all? Perhaps I am missing something. Comment on my notes and let me know more info and maybe we can help.

Sponsor our Newsletter | Privacy Policy | Terms of Service