the error:
Code: Select all
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1Code: Select all
<?php
$connection = mysql_connect ("localhost", "", "") or die ('I cannot connect to the database because: ' . mysql_error());
$db = mysql_select_db ("hillside");
if(!isset($_POSTї'submit'])){
Print <<< EOT
<html><head><title>Addpiece</title></head><body><div align="center"><center>
<form method="POST" enctype="multipart/form-data" action="addpiece.php"><center>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse:collapse" bordercolor="#111111" width="342">
<tr><td width="343" colspan="2"><p align="center">Add New Piece</td></tr><tr><td width="94"><p align="center">PieceNumber:</td>
<td width="248"><p align="center"><input type="text" name="itemnum"></td></tr><tr><td width="94"><p align="center">Name:</td>
<td width="248"><p align="center"><input type="text" name="title"></td></tr><tr><td width="94"><p align="center">Catagory:</td>
<td width="248"><p align="center"><select name="catagory"><option value="" selected>Please choose catagory</option>
EOT;
$query = mysql_query("SELECT * FROM catagory");
while($array = mysql_fetch_array($query)) {
Print '<option value="'.$arrayї'id'].'">'.$arrayї'title'].'</option>';
}
PRINT <<< EOT
</select></td></tr><tr><td width="94"><p align="center">Height:</td>
<td width="248"><p align="center"><input type="text" name="height"></td></tr><tr><td width="94"><p align="center">Width:</td>
<td width="248"><p align="center"><input type="text" name="width"></td></tr><tr><td width="94"><p align="center">Depth:</td>
<td width="248"><p align="center"><input type="text" name="depth"></td></tr><tr><td width="94"><p align="center">Image:</td>
<td width="248"><p align="center"><input type="file" name="file"></td></tr><tr><td width="343" colspan="2"><p align="center">
<input type="submit" value="Submit" name="submit"> <input type="reset" value="Reset" name="reset"></td>
</tr></table></center></div></form></center></div></body></html>
EOT;
}
if(isset($_POSTї'submit'])) {
function makethumb($sourcefile, $destfile, $imgcomp = 0)
{
$g_imgcomp=100-$imgcomp;
$g_srcfile=$sourcefile;
$g_dstfile=$destfile;
if(file_exists($g_srcfile))
{
$g_is=getimagesize($g_srcfile);
$g_fw=$g_isї0]/4;
$g_fh=$g_isї1]/4;
if(($g_isї0]-$g_fw)>=($g_isї1]-$g_fh))
{
$g_iw=$g_fw;
$g_ih=($g_fw/$g_isї0])*$g_isї1];
}
else
{
$g_ih=$g_fh;
$g_iw=($g_ih/$g_isї1])*$g_isї0];
}
$img_src=imagecreatefromjpeg($g_srcfile);
$img_dst=imagecreate($g_iw,$g_ih);
imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $g_iw, $g_ih, $g_isї0], $g_isї1]);
imagejpeg($img_dst, $g_dstfile, $g_imgcomp);
imagedestroy($img_dst);
return true;
}
else
return false;
}
$filename = eregi_replace(" ","_",$_FILESї"userfile"]ї"name"]);
$query = mysql_query("INSERT INTO furniture (itemnum,title,catagory,height,width,depth,image) VALUES ({$_POSTї'itemnum']},{$_POSTї'title']}.{$_POSTї'catagory']},{$_POSTї'height']},{$_POSTї'width']},{$_POSTї'depth']},{$filename})") or die(mysql_error());
if($query) {
echo "Information Inserted into the Database Correctly!";
}
$filecopy = copy($_FILESї"file"]ї"tmp_name"], "images/" . $filename);
if($filecopy) {
echo "Image Copied to Images Folder Correctly!";
}
$makethumbnail = makethumb("images/".$_FILESї"file"]ї"name"],"images/thumbnails/thumb_".$filename,0);
if($filecopy) {
echo "Thumbnail Image Made Correctly!";
}
}
?>~Dull1554