close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Linking SQL database with uploaded image thru DigitalFilePro

Thread began 2/03/2010 2:32 pm by jeff390862 | Last modified 2/04/2010 12:09 pm by jeff390862 | 890 views | 1 replies

jeff390862

Linking SQL database with uploaded image thru DigitalFilePro

I'm having some trouble "pushing" the dynamically created file name of uploaded images generated by the Digital File Pro (DFP) PHP code into the appropriate column in the MySQL database I've created. I'm using DFP independently, not with DataAssist (although I have access to this). I'd prefer not to use DataAssist in this case, since I've already built my record insertion structure and don't really want to make changes if I don't have to - I believe the trouble I'm having is merely finding out what information DFP is generating, where in the code it's being generated, and how I can send that info to the column in the MySQL database.

The MySQL column is called "images". The input type is "text". I've created a File Field in DW4, linked it to the DFP, included all my specifics, etc., and am getting the error "Column "images" cannot be null". My database is designed not to accept an empty field in this column, so the error message is doing its job. However, I want to be able to send the dynamically created name of the image file to the MySQL "images" column, with the goal of retrieving that information in myriad search results. In my webpage code, I'm seeing that the statements relating to the insertion of data into the MySQL database reference the ID, which is called "images", to match the dbase column name. However, no value is being represented there, which is what I believe should be passed to the dbase column. I've tried just about every possible combination of naming structures, (including PHP code to echo, post or get info from the DFP PHP code), in the "Values" column, and continue to get the same results. Removing the image upload functionality from the page allows all other dbase columns to populate properly, which tells me that I'm connecting successfully to the dbase.

The image upload folder called "property images" is in place, in case that was a question.

I'm adding the applicable page code below. If anyone can help, I've spent more sleepless nights than I care to admit trying to fix this. I would deeply appreciate any help.

Page code:
<?php require_once('Connections/pendragon.php'); ?>
<?php require_once("WA_DigitalFilePro/HelperPHP.php"); ?>
<?php if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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 pendragonproperties (propertytype, address, bedrooms, bathrooms, price, wdhookup, dishwasher, porch, pets, transit, parking, fireplace, hardwood, handicap, laundry, neighborhood, images, availability) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['propertytype'], "text"),
GetSQLValueString($_POST['address'], "text"),
GetSQLValueString($_POST['bedrooms'], "int"),
GetSQLValueString($_POST['bathrooms'], "int"),
GetSQLValueString($_POST['price'], "text"),
GetSQLValueString(isset($_POST['wdhookup']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['dishwasher']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['porch']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['pets']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['transit']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['parking']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['fireplace']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['hardwood']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['handicap']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['laundry']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($_POST['neighborhood'], "text"),
GetSQLValueString($_POST['images'], "text"),
GetSQLValueString($_POST['availability'], "date"));
mysql_select_db($database_pendragon, $pendragon);
$Result1 = mysql_query($insertSQL, $pendragon) or die(mysql_error());
$insertGoTo = "admin_updated.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
mysql_select_db($database_pendragon, $pendragon);
$query_availability = "SELECT availability FROM pendragonproperties WHERE availability = availability";
$availability = mysql_query($query_availability, $pendragon) or die(mysql_error());
$row_availability = mysql_fetch_assoc($availability);
$totalRows_availability = mysql_num_rows($availability);
mysql_select_db($database_pendragon, $pendragon);
$query_inputproperty = "SELECT propertytype, address, bedrooms, bathrooms, price, wdhookup, dishwasher, porch, pets, transit, parking, fireplace, hardwood, handicap, laundry, neighborhood, images FROM pendragonproperties";
$inputproperty = mysql_query($query_inputproperty, $pendragon) or die(mysql_error());
$row_inputproperty = mysql_fetch_assoc($inputproperty);
$totalRows_inputproperty = mysql_num_rows($inputproperty);?>
<?php
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "propertyimages/",
'FileName' => "(FileName}",
'DefaultFileName' => "propertyimages/defaultimage.png",
'ResizeType' => "2",
'ResizeWidth' => "220",
'ResizeHeight' => "120",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult1_1 End
// WA_UploadResult1_2 Start
$WA_UploadResult1_Params["WA_UploadResult1_2"] = array(
'UploadFolder' => "Images/",
'FileName' => "[FileName]_thumb",
'DefaultFileName' => "propertyimages/defaultimageTHUMB.png",
'ResizeType' => "2",
'ResizeWidth' => "120",
'ResizeHeight' => "120",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult1_2 End
// WA_UploadResult1 Params End
?>
<?php?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if(isset($_POST["submitbutton2"])){
WA_DFP_UploadFiles("WA_UploadResult1", "images", "0", "", "PNG:0", $WA_UploadResult1_Params);
}?>

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...