Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP/MySQL - Data not Saving to Database

Status
Not open for further replies.

eclipse33

Programmer
Apr 13, 2001
94
0
0
CA
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(&quot;top.php&quot;); ?>

<?

if ($eid && $date && $caption) {

if (!mysql_query(&quot;INSERT INTO DOME_staff (eventid, date, caption) VALUES ('$eid', '$date', '$caption')&quot;)) {

echo &quot;Error saving picture: &quot; . 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(&quot;../photos/%010d-sta.%s&quot;, $pictureid, $fileinfo['extension']));

move_uploaded_file($location, $filename);

mysql_query(&quot;UPDATE DOME_staff SET filename='$filename' WHERE id='$pictureid'&quot;);

} // End if

echo &quot;Picture successfully added.<br><a href='staff_list.php?id=$id'>Back</a>&quot;;

} // End if

exit;

} // End if

?>

<strong>Add picture</strong>

<form method=post action=&quot;<?=$PHP_SELF;?>&quot; enctype=&quot;multipart/form-data&quot;>

<input type=hidden name=eid value=&quot;<?=$eid;?>&quot;>

<table width=&quot;500&quot;>
<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=&quot;Save&quot;>

</form>

<? include(&quot;bottom.php&quot;); ?>



BELOW is code for the page that lists the individual photos for a group (works fine)


<? include(&quot;top.php&quot;); ?> <a href=&quot;staff_add.php?id=<?=$id;?>&quot;>Add picture</a> <br><br>

<table width=&quot;400&quot; 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(&quot;SELECT id, filename, date, caption FROM DOME_staff WHERE eventid='$id' ORDER BY id ASC&quot;);

while (list($pid, $filename, $ts, $caption) = mysql_fetch_row($result)) {

$i++;

?>

<tr valign=&quot;top&quot;>

<td align=center>
<?=$i;?>
</td>

<td>
<?=$ts;?>
</td>

<td><img src=&quot;<?=$filename;?>&quot; border=0 width=100 height=70></td>

<td>
<?=$caption;?>
</td>

<td><a href=&quot;staff_edit.php?pid=<?=$pid;?>&quot;>Edit</a></td>
<td><a href=&quot;staff_delete.php?pid=<?=$pid;?>&quot;>Delete</a></td>

</tr>

<?

} // End while

?>
</table>
<? include(&quot;bottom.php&quot;); ?>

Any help would REALLY be appreciated!

Thanks in advance.
eclipse33
[pacman]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top