Hope someone can help...I inherited this problem and this is my first MySQL job.
I have an admin section for a website that allows the client to login, create a group of photos and then add individual photos to each group.
The client can create the group fine but when they try to add individual pictures it will not save.
Below is the code for the add/save picture page and then below that is the code for the page that displays back the individual pictures in a specific group (this page works fine because there is a group of 7 pics that show up fine - only problem is new pictures can't be added)
<? include("top.php"
; ?>
<?
if ($eid && $date && $caption) {
if (!mysql_query("INSERT INTO DOME_staff (eventid, date, caption) VALUES ('$eid', '$date', '$caption')"
) {
echo "Error saving picture: " . mysql_error();
} else {
$pictureid = mysql_insert_id();
$userfile = $HTTP_POST_FILES['picture']['name'];
$location = $HTTP_POST_FILES['picture']['tmp_name'];
if ($userfile && is_uploaded_file($location)) {
$fileinfo = pathinfo($userfile);
$filename = mysql_escape_string(sprintf("../photos/%010d-sta.%s", $pictureid, $fileinfo['extension']));
move_uploaded_file($location, $filename);
mysql_query("UPDATE DOME_staff SET filename='$filename' WHERE id='$pictureid'"
;
} // End if
echo "Picture successfully added.<br><a href='staff_list.php?id=$id'>Back</a>";
} // End if
exit;
} // End if
?>
<strong>Add picture</strong>
<form method=post action="<?=$PHP_SELF;?>" enctype="multipart/form-data">
<input type=hidden name=eid value="<?=$eid;?>">
<table width="500">
<tr>
<td><strong>Date:</strong></td>
<td><input type=text name=date></td>
</tr>
<tr>
<td><strong>Caption:</strong></td>
<td><input type=text name=caption></td>
</tr>
<tr>
<td><strong>File:</strong></td>
<td><input type=file name=picture></td>
</tr>
</table>
<input type=submit value="Save">
</form>
<? include("bottom.php"
; ?>
BELOW is code for the page that lists the individual photos for a group (works fine)
<? include("top.php"
; ?> <a href="staff_add.php?id=<?=$id;?>">Add picture</a> <br><br>
<table width="400" border=0 cellpadding=4 cellspacing=1>
<tr>
<td><strong>#</strong></td>
<td><strong>Date</strong></td>
<td><strong>Picture</strong></td>
<td><strong>Caption</strong></td>
</tr>
<?
$i = 0;
$result = mysql_query("SELECT id, filename, date, caption FROM DOME_staff WHERE eventid='$id' ORDER BY id ASC"
;
while (list($pid, $filename, $ts, $caption) = mysql_fetch_row($result)) {
$i++;
?>
<tr valign="top">
<td align=center>
<?=$i;?>
</td>
<td>
<?=$ts;?>
</td>
<td><img src="<?=$filename;?>" border=0 width=100 height=70></td>
<td>
<?=$caption;?>
</td>
<td><a href="staff_edit.php?pid=<?=$pid;?>">Edit</a></td>
<td><a href="staff_delete.php?pid=<?=$pid;?>">Delete</a></td>
</tr>
<?
} // End while
?>
</table>
<? include("bottom.php"
; ?>
Any help would REALLY be appreciated!
Thanks in advance.
eclipse33
![[pacman] [pacman] [pacman]](/data/assets/smilies/pacman.gif)
I have an admin section for a website that allows the client to login, create a group of photos and then add individual photos to each group.
The client can create the group fine but when they try to add individual pictures it will not save.
Below is the code for the add/save picture page and then below that is the code for the page that displays back the individual pictures in a specific group (this page works fine because there is a group of 7 pics that show up fine - only problem is new pictures can't be added)
<? include("top.php"
<?
if ($eid && $date && $caption) {
if (!mysql_query("INSERT INTO DOME_staff (eventid, date, caption) VALUES ('$eid', '$date', '$caption')"
echo "Error saving picture: " . mysql_error();
} else {
$pictureid = mysql_insert_id();
$userfile = $HTTP_POST_FILES['picture']['name'];
$location = $HTTP_POST_FILES['picture']['tmp_name'];
if ($userfile && is_uploaded_file($location)) {
$fileinfo = pathinfo($userfile);
$filename = mysql_escape_string(sprintf("../photos/%010d-sta.%s", $pictureid, $fileinfo['extension']));
move_uploaded_file($location, $filename);
mysql_query("UPDATE DOME_staff SET filename='$filename' WHERE id='$pictureid'"
} // End if
echo "Picture successfully added.<br><a href='staff_list.php?id=$id'>Back</a>";
} // End if
exit;
} // End if
?>
<strong>Add picture</strong>
<form method=post action="<?=$PHP_SELF;?>" enctype="multipart/form-data">
<input type=hidden name=eid value="<?=$eid;?>">
<table width="500">
<tr>
<td><strong>Date:</strong></td>
<td><input type=text name=date></td>
</tr>
<tr>
<td><strong>Caption:</strong></td>
<td><input type=text name=caption></td>
</tr>
<tr>
<td><strong>File:</strong></td>
<td><input type=file name=picture></td>
</tr>
</table>
<input type=submit value="Save">
</form>
<? include("bottom.php"
BELOW is code for the page that lists the individual photos for a group (works fine)
<? include("top.php"
<table width="400" border=0 cellpadding=4 cellspacing=1>
<tr>
<td><strong>#</strong></td>
<td><strong>Date</strong></td>
<td><strong>Picture</strong></td>
<td><strong>Caption</strong></td>
</tr>
<?
$i = 0;
$result = mysql_query("SELECT id, filename, date, caption FROM DOME_staff WHERE eventid='$id' ORDER BY id ASC"
while (list($pid, $filename, $ts, $caption) = mysql_fetch_row($result)) {
$i++;
?>
<tr valign="top">
<td align=center>
<?=$i;?>
</td>
<td>
<?=$ts;?>
</td>
<td><img src="<?=$filename;?>" border=0 width=100 height=70></td>
<td>
<?=$caption;?>
</td>
<td><a href="staff_edit.php?pid=<?=$pid;?>">Edit</a></td>
<td><a href="staff_delete.php?pid=<?=$pid;?>">Delete</a></td>
</tr>
<?
} // End while
?>
</table>
<? include("bottom.php"
Any help would REALLY be appreciated!
Thanks in advance.
eclipse33
![[pacman] [pacman] [pacman]](/data/assets/smilies/pacman.gif)