[SOLVED] Call to undefined function
Posted: Sun Mar 13, 2005 6:35 pm
Hi,
with the following code .. It all works fine as it is ..
But soon as I add the following code around it:
I get an error like so:
I have no idea why .. How can I fix this?
Thanks
with the following code .. It all works fine as it is ..
Code: Select all
<?php
include("config.inc.php");
if( empty($_POST['action']) )
{
}
else if( strcasecmp($_POST['action'], "Find Photo")==0 )
{
$result = mysql_query( "SELECT photo_caption,photo_filename,photo_category FROM gallery_photos WHERE photo_id='".addslashes($_POST['photoid'])."'" );
$nr = mysql_num_rows( $result );
if( $nr < 1 )
{
echo("<font class=\"txt\">Photo not found in DB</font><br>");
echo("<br><font class=\"txt\"><a href=\"../index.php?pages=adminindex\">Back to Photogallery Admin Page</a></font><br><br>");
return;
}
$row = mysql_fetch_array( $result );
mysql_free_result( $result );
echo("<font class=\"txt\">Picture ID: ".$_POST['photoid']."</text><br><br>");
echo("<a href='index.php?cid=".$row['photo_category']."&pid=".$_POST['photoid']."'><img src='".$images_dir."/tb_".$row[1]."' border='1' alt='".$row[0]."' /></a>");
$result = mysql_query( "SELECT category_id,category_name FROM gallery_category" );
while( $row2 = mysql_fetch_array( $result ) )
{
if( $row2["category_id"] == $row["photo_category"] )
{
$category_list .=<<<__HTML_END
<option value="$row2[0]" selected>$row2[1]</option>\n
__HTML_END;
}
else
{
$category_list .=<<<__HTML_END
<option value="$row2[0]">$row2[1]</option>\n
__HTML_END;
}
}
mysql_free_result( $result );
$category_list = '<select name="categoryid">'.$category_list.'</select>';
?>
<form name="photo_move" action="../index.php?pages=edit_photo" method="post">
<div align="center"><b><font class="txt">Move Photo / Update Caption:</font></b><br>
<font class="txt"><br>
Select New Category:<br>
<br>
<?php echo($category_list); ?></font><br>
<br>
<font class="txt">Update Caption:<br>
</font><br>
<textarea name="caption" cols="45" rows="1"><?php echo($row["photo_caption"]); ?></textarea>
<br>
<br>
<input type="hidden" value="<?php echo($_POST['photoid']); ?>" name="photoid" />
<input type="submit" value="Submit" name="action" class='submit-button'>
</div>
</form>
<div align="center"><br>
</div>
<form name="photo_delete" action="../index.php?pages=edit_photo" method="post">
<div align="center"><b><font class="txt">Delete Photo:</font></b><br>
<br>
<input type="hidden" value="<?php echo($_POST['photoid']); ?>" name="photoid" />
<input type="submit" value="Delete This Photo?" name="action" class="submit-button" onclick="return confirm('Are you sure you want to do delete this photo?')" />
</div>
</form>
<center><font class="txt"><a href="../index.php?pages=adminindex">Back to Photogallery Admin Page</a></font></center><br><br>
<?php
}
else
{
if( strcasecmp($_POST['action'], "Submit")==0 && !empty( $_POST['categoryid'] ) )
{
edit_photo($_POST['photoid'], $_POST['caption'], $_POST['categoryid']);
}
else if( strcasecmp($_POST['action'], "Delete This Photo?")==0 && !empty( $_POST['photoid'] ) )
{
delete_photo($_POST['photoid']);
}
else
{
echo("Action not understood"); return;
}
echo("<font class=\"txt\">Process completed</font><br>");
echo("<br><font class=\"txt\"><a href='../index.php?pages=adminindex'>Back to Administration Page</a></font><br><br>");
}
function edit_photo( $photo_id, $new_caption, $new_category )
{
mysql_query( "UPDATE gallery_photos SET photo_caption='".addslashes( $new_caption )."', photo_category='".addslashes( $new_category )."' WHERE photo_id='".addslashes( $photo_id )."'" );
}
function delete_photo($photo_id)
{
global $images_dir;
$result = mysql_query("
SELECT photo_filename
FROM gallery_photos
WHERE photo_id = '" . addslashes($photo_id) . "'
");
list($filename) = mysql_fetch_array($result);
mysql_free_result($result);
unlink($images_dir . '/' . $filename);
unlink($images_dir . '/tb_' . $filename);
mysql_query("
DELETE FROM gallery_photos
WHERE photo_id='" . addslashes($photo_id) . "'");
}
?>Code: Select all
if(($_SESSION['user_level'] == 2) || ($_SESSION['user_level'] == 3)) {
// Above code here
} else {
echo "<font class=\"txt\">You are either not logged in, or dont have permission to be here!</font><br><br>";
echo "<font class=\"txt\"><a href=\"../index.php?pages=login_form\">Login Here</a></font><br><br>";
}Code: Select all
Fatal error: Call to undefined function: edit_photo() in /home/noname/public_html/album/edit_photo.php on line 87Thanks