I have the following code which uploads a photograph supplied by the user, adds it to the photo library and then gives it a catalogue number. The catalogue number is based on two things, the number + 1 of the last uploaded image and the two letter photographer name.
The upload side of things works fine and the page access the database ok. However i get an
Parse error: parse error, unexpected $ in /mounted-storage/home4/sub002/xxxx/www/abc1x09az/upload/upload2.php on line 74
as line 74 is </BODY> can anyone suggest what i'm doing wrong?
I'm new to PHP having been an ASP coder (ok ok, I'm sorry!!!!!) for the past few years!
Also can anyone point me in the right direction for how to pull EXIF data out of an image file and store it in the database?
Thanks in advance for any help!
Rich
UPLOAD2.PHP:
<?php
include '../library/chksession.php';
?>
<HTML>
<HEAD>
<TITLE>rx</TITLE>
</HEAD>
<BODY LEFTMARGIN=0 TOPMARGIN=0>
<TABLE WIDTH=750 ALIGN=CENTER BORDER=0 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD COLSPAN=3 ALIGN=LEFT><IMG SRC="../graphics/topbar.jpg" ALIGN=RIGHT>
<FONT FACE="Tahoma" SIZE=7 COLOR=#000066><B>rx</B></FONT></TD>
</TR>
<TR BGCOLOR=#000066>
<TD COLSPAN=3> <FONT FACE="Tahoma" SIZE=3 COLOR=#FFFFFF><B>Add new image to library</B></FONT></TD>
</TR>
<TR VALIGN=TOP COLSPAN=3 ALIGN=CENTER><TD COLSPAN=3>
<?
// always check the file size - here it's set to a max of 20MB
if ($FILES['uploadfile']['size'] <=20000000) {
$tmp_name = $FILES['uploadfile']['tmp_name'];
$new_name = "../imagestore/".$FILES['uploadfile']['name'];
if (move_uploaded_file($tmp_name, $new_name)) {
print "<B>" . $FILES['uploadfile']['name'] . "</B><BR>";
include '../library/dbconnect.php';
echo 'Username: ';
echo $_SESSION[ 'userlogged'];
$uname = $_SESSION[ 'userlogged'];
$sql = "SELECT catcode FROM rx_users WHERE userloginname = $uname";
$result = mysql_query($sql)
or die('Query failed. ' . mysql_error());
if (mysql_numrows($result) == 1) {
$row=mysql_fetch_assoc($result); // Get data associated with SELECT statment from table
$catcode = $row[catcode];
$sql2 = "SELECT catnumb FROM rx_uploads WHERE uploadmonth = ".date("m")." AND uploadyear = ".date("Y")." ORDER BY catnumb desc";
$result2 = mysql_query($sql2)
or die('Query failed. ' . mysql_error());
if (mysql_numrows($result) == 1) {
$row2=mysql_fetch_assoc($result); // Get data associated with SELECT statment from table
$catnumber = $row2[catnumb] + 1;
} else {
$catnumber = 1;
}
mysql_close($connection);
} else {
print "The file was not successfully uploaded to $new_name";
}
} else {
print "File is too large to upload - please upload a smaller file";
}
?>
<img src="../phpthumb/phpThumb.php?src=<?php echo $new_name ?>&w=530" BORDER=1>
<FORM METHOD=POST ACTION="upload3.php">
<TABLE WIDTH=80% ALIGN=CENTER>
<INPUT TYPE=HIDDEN NAME='originalfilename' VALUE='<?php echo $FILES['uploadfile']['name'] ?>'>
<TR><TD WIDTH=200><B>Filename:</B></TD><TD><?php $FILES['uploadfile']['name'] ?></TD></TR>
<TR><TD WIDTH=200><B>Catalogue ID:</B></TD><TD><?php printf($catcode . "D/" . date("Y") . "/" . date("m") . "/" . "%05d", $catnumber) ?></TD></TR>
<TR><TD WIDTH=200><B>Vehicle:</B></TD><TD><INPUT TYPE='TEXT' NAME='vehicleno'></TD></TR>
<TR><TD WIDTH=200><B>Date (in dd/mm/yyyy format):</B></TD><TD><INPUT TYPE='TEXT' NAME='picturedate'></TD></TR>
<TR><TD WIDTH=200><B>Location:</B></TD><TD><SELECT><OPTION VALUE='A'>
</SELECT></TD></TR>
<TR><TD WIDTH=200><B>Caption Details:</B></TD><TD><TEXTAREA ROWS=5 COLS=40 NAME='caption'></TEXTAREA></TD></TR>
<TR><TD COLSPAN=2><INPUT TYPE=SUBMIT VALUE='Save Details'></TD></TR>
</TABLE>
</FORM>
</TD></TR>
</TABLE>
</HTML>