penguinmama
12.***.***.***Help! Photo database thing again.
Ok, I found some code that I could tweak to upload the photos. "out of the box" it worked fine. After small tweaking it still worked... now it doesn't. anyone have any ideas?PHP code:
<?
//print_r($_POST);
if($_POST["action"] == "Upload Image")
{
unset($imagename);
if(!isset($_FILES) && isset($HTTP_POST_FILES))
$_FILES = $HTTP_POST_FILES;
if(!isset($_FILES['pic_file']))
$error["pic_file"] = "An image was not found.";
$imagename = basename($_FILES['pic_file']['name']);
$imagesize = basename($_FILES['pic_file']['size']);
$imagetype = basename($_FILES['pic_file']['type']);
//echo $imagename;
if(empty($imagename))
$error["imagename"] = "The name of the image was not found.";
if(empty($error))
{
$newimage = "../housepics/".$imagename;
//echo $newimage;
$result = @move_uploaded_file($_FILES['pic_file']['tmp_name'], $newimage);
if(empty($result))
$error["result"] = "There was an error moving the uploaded file.";
require("/usr/include/web/db.inc");
@ $db = mysql_pconnect($host, $user, $pw);
if (!$db)
{
echo "Error! Could not connect to database. Please try again later.";
echo "<a href=editproperty.php>Return to Edit Interface.</a>";
exit;
}
mysql_select_db("dbname");
$id="'".$_POST['id']."'";
$description="'".$_POST['description']."'";
$newimage="'http://dbdomain.com/housepics/".$imagename."'";
$imagesize="'".$imagesize."'";
$imagetype="'".$imagetype."'";
$query = "INSERT INTO images (id, description, filename, filesize, filetype) VALUES($id, $description, $imagename, $imagesize, $imagetype)";
$result = mysql_query($query) or die(mysql_error());
if (!$result)
{
echo "Error! Could not insert property. Call the webmaster.";
echo "<a href=editproperty.php>Return to Edit Interface.</a>";
exit;
}
echo "<h1>Your information has been inserted into the database.</h1>";
echo "The following is what you entered: ";
echo "ID: $id<br><br>Description: $description<br><br>";
echo "<img src=".$newimage.">";
echo "<a href=editproperty.php>Return to Edit Interface.</a>";
}
}
?>
<form method="POST" enctype="multipart/form-data" name="image_upload_form" action="<?$_SERVER["PHP_SELF"];?>">
<p><input type="file" name="pic_file" size="30"></p>
<p>MLS/ID# this picture goes with: <input type="text" name="id" size="10"></p>
<p>Short Description of the picture: <input type="text" name="description" size="30"></p>
<p><input type="submit" value="Upload Image" name="action"></p>
</form>
<?
if(is_array($error))
{
while(list($key, $val) = each($error))
{
echo $val;
echo "<br>\n";
}
}
?>
It's giving me an error "Unknown table 'filename' in field list" -- I do not understand WHERE it is getting the filename as a table name. I'm very confused. I'm sure (or hoping!) that it is something simple. Help?