Hi - my problem is that I am trying to update from a form. I pass the $HTTP_POST_VARS to the new file. Set a variable to this and try and use the variable in a WHere statement. Thinking that the type might be wrong I then set the type of the variable to integer. I thought this would work. To test I have set a number into the where statement and it works fine so I am doing something wrong with the $variable. The code is as below and the form variable I pass to this file is property.
I have spent three weeks trying to figure this out so any help is greatly received
<?php
include 'db.inc';
$jeremy = $HTTP_POST_VARS['property'];
settype ($jeremy, "integer");
$jeremys = $jeremy;
if (empty($short) || empty($userfile))
{
?>
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Upload an Image File</title>
</head>
<body bgcolor="white">
<form method="post" action="imupdate.php" enctype="multipart/form-data">
<h1>Upload an Image File</h1>
<h3>Please fill in the details below to upload your file.
Fields shown in <font color="red">red</font> are mandatory.</h3>
<table>
<col span="1" align="right">
<tr>
<td>PropertyID</td>
<td><?php echo $jeremy; ?></td>
</tr>
<tr>
<td><font color="red">Short description:</font></td>
<td><input type="text" name="short" size=50></td>
</tr>
<tr>
<td><font color="red">File:</font></td>
<td><input name="userfile" type="file"></td>
</tr>
<tr>
<td><input type="submit" value="Submit"></td>
</tr>
</table>
<input type="hidden" name="MAX_FILE_SIZE" value="30000">
</form>
<h3>Click <a href="index.php">here</a> to browse the images instead.</h3>
<?php echo gettype ($jeremy).'<br />'?>;
<?php echo gettype ($jeremys).'<br />'?>;
<?php echo ($jeremy).'<br />'?>;
<?php echo ($jeremys).'<br />'?>;
<?php echo ($jeremy2).'<br />'?>;
</body>
</html>
<?php
}
else
{
$short = clean($short, 50);
$userfile = clean($userfile, 50);
if (!($connection = @ mysql_pconnect($hostName,
$username,
$password)))
showerror();
if (!mysql_select_db("running2_REMAX", $connection))
showerror();
// Was a file uploaded?
if (is_uploaded_file($userfile))
{
switch ($userfile_type)
{
case "image/gif";
$mimeName = "GIF Image";
break;
case "image/jpeg";
$mimeName = "JPEG Image";
break;
case "image/png";
$mimeName = "PNG Image";
break;
case "image/x-MS-bmp";
$mimeName = "Windows Bitmap";
break;
default:
$mimeName = "Unknown image type";
}
// Open the uploaded file
$file = fopen($userfile, "r");
// Read in the uploaded file
$fileContents = fread($file, filesize($userfile));
// Escape special characters in the file
$fileContents = AddSlashes($fileContents);
}
else
$fileContents = NULL;
$insertQuery = ("UPDATE propertiesall SET carnum = '7',
heading = \"{$short}\",
mimeType = \"{$userfile_type}\",
mimeName = \"{$mimeName}\",
image5 = \"{$fileContents}\" WHERE propertyID='$jeremy'");
if ((@ mysql_query ($insertQuery, $connection))
&& @ mysql_affected_rows() == 1)
header("Location: imagereceipt.php?status=T&file="
. mysql_insert_id($connection));
else
header("Location: imagereceipt.php?status=F&file="
. mysql_insert_id($connection));
} // if else empty()
?>
Thanks for your help
Jeremy