I have built a new site using DWMX 2004 and I am needing to store images for products and parts into my database. I have the tables set correctly as BLOB
when I create an "add record" or "update record" within dreamweaver I do NOT have the option to upload the "file field" as "blob" or "bin_data" I wanted to know if anyone out there has stumbled accrossed a way or knows how to modify the dreamweaver generated code for the functions to accept the "blob" or "bin_data" format and upload images into a MySql database?
I have use sample code that I have gotten from developers that do NOT use dreamweaver and I can upload the images into the database so I know my database is able to store the images but the problem I am having is that I can not get this code to intagrate with the dreamweaver code so I can upload the images at the same time the records are being added or updated.
I have pasted my form & code below and you will see that dreamweaver wants to treat the "images" as text and I was hoping that someone out here can look at my code and tell me how to modify this and get it to work. One developer I have talked to told me to scrap using Dreamweaver all together but I can't do this, I am new to PHP and I feel that dreamweaver is a very good tool to use and I have no troubles at all with any of dreamweavers code or even modifing code as needed until now.
if you wish to contact me:
Phone: 888-543-8024 (USA Toll Free)
email: jim@websbydesign.net
Skype: websbydesign
MSN: websbydesign
Yahoo: websbydesignllc
Below is the form & code in question:
==========================================================
The Form I am using:
<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1">
<input type="text" name="part_number" value="" size="15">
<input type="text" name="part_name" value="" size="15">
<input name="short_description" type="text" size="32">
<textarea name="part_desricption" cols="50" rows="5"></textarea>
<input type="text" name="part_price" value="" size="10">
<input type="text" name="part_cost" value="" size="10">
<input type="file" name="image">
<input type="file" name="image_thumb">
<input type="hidden" name="part_id">
<input type="submit" value="Add">
<input type="hidden" name="MM_insert" value="form1">
</form>
==========================================================
The Code Dreamweaver generated for the above form:
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $SERVER['PHP_SELF'];
if (isset($SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($POST["MM_insert"])) && ($POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO parts (part_id, part_number, part_name, part_desricption, part_price, part_cost, image, image_thumb, short_description) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($POST['part_id'], "int"),
GetSQLValueString($POST['part_number'], "text"),
GetSQLValueString($POST['part_name'], "text"),
GetSQLValueString($POST['part_desricption'], "text"),
GetSQLValueString($POST['part_price'], "text"),
GetSQLValueString($POST['part_cost'], "text"),
GetSQLValueString($POST['image'], "text"),
GetSQLValueString($POST['image_thumb'], "text"),
GetSQLValueString($_POST['short_description'], "text"));
mysql_select_db($database_HPC_parts, $HPC_parts);
$Result1 = mysql_query($insertSQL, $HPC_parts) or die(mysql_error());
$insertGoTo = "index.php";
if (isset($SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_HPC_parts, $HPC_parts);
$query_RSadd_parts = "SELECT * FROM parts";
$RSadd_parts = mysql_query($query_RSadd_parts, $HPC_parts) or die(mysql_error());
$row_RSadd_parts = mysql_fetch_assoc($RSadd_parts);
$totalRows_RSadd_parts = mysql_num_rows($RSadd_parts);
?>