close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

upload to database

Thread began 5/19/2009 10:26 am by george50130 | Last modified 5/20/2009 1:10 pm by Ray Borduin | 4388 views | 11 replies |

george50130

upload to database

OK I'm making decent progress with my admin area.

I used DataAssist to create all my product page tools.

I then replaced the textfields for my product images with a file upload field of the same name and went through the digital upload settings and came across to errors (thankfully as DW was crashing last night.

I then changed the productImage detail page to display an image rather than text. Looking at the source code displayed on the prod detail page it shows:

<img src="forming-cream.jpg" />

however, the path is incorrect. How can I rectify it?

Thanks in advance,
G

Sign in to reply to this post

Ray BorduinWebAssist

What is the correct path? Just go in and add the folder before the database reference so that the path will be correct.

Sign in to reply to this post
Did this help? Tips are appreciated...

george50130

the correct path should be /images/products/large/forming-cream.jpg

Although I've just noticed that the file isn't actually in place at all.

Code looks like so:

<?php require_once("../Connections/connHCHQ.php"); ?>
<?php require_once("../WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php require_once("../WA_DigitalFilePro/HelperPHP.php"); ?>
<?php require_once('../Connections/connHCHQ.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;
}
}
?>
<?php
$maxRows_WADADynListproductbrand = 1000;
$pageNum_WADADynListproductbrand = 0;
if (isset($_GET['pageNum_WADADynListproductbrand'])) {
$pageNum_WADADynListproductbrand = $_GET['pageNum_WADADynListproductbrand'];
}
$startRow_WADADynListproductbrand = $pageNum_WADADynListproductbrand * $maxRows_WADADynListproductbrand;

mysql_select_db($database_connHCHQ, $connHCHQ);
$query_WADADynListproductbrand = "SELECT brandID, brandName FROM productbrand ORDER BY brandName";
$query_limit_WADADynListproductbrand = sprintf("%s LIMIT %d, %d", $query_WADADynListproductbrand, $startRow_WADADynListproductbrand, $maxRows_WADADynListproductbrand);
$WADADynListproductbrand = mysql_query($query_limit_WADADynListproductbrand, $connHCHQ) or die(mysql_error());
$row_WADADynListproductbrand = mysql_fetch_assoc($WADADynListproductbrand);

if (isset($_GET['totalRows_WADADynListproductbrand'])) {
$totalRows_WADADynListproductbrand = $_GET['totalRows_WADADynListproductbrand'];
} else {
$all_WADADynListproductbrand = mysql_query($query_WADADynListproductbrand);
$totalRows_WADADynListproductbrand = mysql_num_rows($all_WADADynListproductbrand);
}
$totalPages_WADADynListproductbrand = ceil($totalRows_WADADynListproductbrand/$maxRows_WADADynListproductbrand)-1;
?>
<?php
$maxRows_WADADynListprodcategory = 1000;
$pageNum_WADADynListprodcategory = 0;
if (isset($_GET['pageNum_WADADynListprodcategory'])) {
$pageNum_WADADynListprodcategory = $_GET['pageNum_WADADynListprodcategory'];
}
$startRow_WADADynListprodcategory = $pageNum_WADADynListprodcategory * $maxRows_WADADynListprodcategory;

mysql_select_db($database_connHCHQ, $connHCHQ);
$query_WADADynListprodcategory = "SELECT CatID, CatName FROM prodcategory ORDER BY CatName";
$query_limit_WADADynListprodcategory = sprintf("%s LIMIT %d, %d", $query_WADADynListprodcategory, $startRow_WADADynListprodcategory, $maxRows_WADADynListprodcategory);
$WADADynListprodcategory = mysql_query($query_limit_WADADynListprodcategory, $connHCHQ) or die(mysql_error());
$row_WADADynListprodcategory = mysql_fetch_assoc($WADADynListprodcategory);

if (isset($_GET['totalRows_WADADynListprodcategory'])) {
$totalRows_WADADynListprodcategory = $_GET['totalRows_WADADynListprodcategory'];
} else {
$all_WADADynListprodcategory = mysql_query($query_WADADynListprodcategory);
$totalRows_WADADynListprodcategory = mysql_num_rows($all_WADADynListprodcategory);
}
$totalPages_WADADynListprodcategory = ceil($totalRows_WADADynListprodcategory/$maxRows_WADADynListprodcategory)-1;?>
<?php
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "../images/products/large/",
'FileName' => "[FileName]",
'DefaultFileName' => "",
'ResizeType' => "0",
'ResizeWidth' => "120",
'ResizeHeight' => "120",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult1_1 End
// WA_UploadResult1 Params End?>
<?php
// WA_UploadResult2 Params Start
$WA_UploadResult2_Params = array();
// WA_UploadResult2_1 Start
$WA_UploadResult2_Params["WA_UploadResult2_1"] = array(
'UploadFolder' => "../images/products/thumbs/",
'FileName' => "[FileName]",
'DefaultFileName' => "",
'ResizeType' => "0",
'ResizeWidth' => "120",
'ResizeHeight' => "120",
'ResizeFillColor' => "#FFFFFF" );
// WA_UploadResult2_1 End
// WA_UploadResult2 Params End
?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if($_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_UploadFiles("WA_UploadResult1", "ProdImage", "2", "[NewFileName]_[Increment]", "true", $WA_UploadResult1_Params);
}?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult2");
if($_SERVER["REQUEST_METHOD"] == "POST"){
WA_DFP_UploadFiles("WA_UploadResult2", "ProdThumb", "2", "[NewFileName]_[Increment]", "true", $WA_UploadResult2_Params);
}
?>
<?php
// WA Application Builder Insert
if (isset($_POST["Insert_x"])) // Trigger
{
$WA_connection = $connHCHQ;
$WA_table = "products";
$WA_sessionName = "WADA_Insert_products";
$WA_redirectURL = "products_Detail.php";
$WA_keepQueryString = false;
$WA_indexField = "ProdID";
$WA_fieldNamesStr = "ProdID|ProdBrandID|ProdName|ProdShortDesc|ProdLongDesc|ProdKeywords|ProdPrice|ProdRRP|ProdSKU|ProdThumb|ProdThumbAlt|ProdImage|ProdImageAlt|ProdCatID|ProdIsFeatured|ProdIsActive|ProdStockAvailability";
$WA_fieldValuesStr = "".((isset($_POST["ProdID"]))?$_POST["ProdID"]:"") ."" . "|" . "".((isset($_POST["ProdBrandID"]))?$_POST["ProdBrandID"]:"") ."" . "|" . "".((isset($_POST["ProdName"]))?$_POST["ProdName"]:"") ."" . "|" . "".((isset($_POST["ProdShortDesc"]))?$_POST["ProdShortDesc"]:"") ."" . "|" . "".((isset($_POST["ProdLongDesc"]))?$_POST["ProdLongDesc"]:"") ."" . "|" . "".((isset($_POST["ProdKeywords"]))?$_POST["ProdKeywords"]:"") ."" . "|" . "".((isset($_POST["ProdPrice"]))?$_POST["ProdPrice"]:"") ."" . "|" . "".((isset($_POST["ProdRRP"]))?$_POST["ProdRRP"]:"") ."" . "|" . "".((isset($_POST["ProdSKU"]))?$_POST["ProdSKU"]:"") ."" . "|" . "".((isset($_POST["ProdThumb"]))?$_POST["ProdThumb"]:"") ."" . "|" . "".((isset($_POST["ProdThumbAlt"]))?$_POST["ProdThumbAlt"]:"") ."" . "|" . "".((isset($_POST["ProdImage"]))?$_POST["ProdImage"]:"") ."" . "|" . "".((isset($_POST["ProdImageAlt"]))?$_POST["ProdImageAlt"]:"") ."" . "|" . "".((isset($_POST["ProdCatID"]))?$_POST["ProdCatID"]:"") ."" . "|" . "".((isset($_POST["ProdIsFeatured"]))?$_POST["ProdIsFeatured"]:"") ."" . "|" . "".((isset($_POST["ProdIsActive"]))?$_POST["ProdIsActive"]:"") ."" . "|" . "".((isset($_POST["ProdStockAvailability"]))?$_POST["ProdStockAvailability"]:"") ."";
$WA_columnTypesStr = "none,none,NULL|none,none,NULL|',none,''|',none,''|',none,''|',none,''|none,none,NULL|none,none,NULL|',none,''|',none,''|',none,''|',none,''|',none,''|none,none,NULL|none,none,NULL|none,none,NULL|none,none,NULL";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_connHCHQ;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$_SESSION[$WA_sessionName] = mysql_insert_id();
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>
{my html is in here}
<?php
mysql_free_result($WADADynListproductbrand);
?>
<?php
mysql_free_result($WADADynListprodcategory);
?>


Not sure if you can control the forum Ray but the code highlighting functionality would be a great addition in these forums.

Sign in to reply to this post

george50130

Followed this 05_upload_insert.swf to the letter and still no joy

Sign in to reply to this post

Ray BorduinWebAssist

you currently have:

<img src="<?php echo($row_RSName['ImageField']); ?>" />

change it to:

<img src="/images/products/large/<?php echo($row_RSName['ImageField']); ?>" />

Then the path will appear correct.

Next you can work on why the image isn't uploading.

Sign in to reply to this post
Did this help? Tips are appreciated...

george50130

Thanks Ray - managed to get it sorted.

Actually sorted the upload first and then the display.

I remembered that my image wasn't actually uploaded to the database but the path to the database and the physical file in a directory.

Sign in to reply to this post

george50130

can you point me in the direction of the next part of 05_upload_insert.swf

Sign in to reply to this post

Ray BorduinWebAssist

Not sure what you mean by the next part. What are you trying to do? What happens when you try?

Sign in to reply to this post
Did this help? Tips are appreciated...

george50130

it's the update record part that the last few moments of that tutorial mentions.

Sign in to reply to this post

Ray BorduinWebAssist

What is confusing about it? What have you tried? Where exactly do you get stuck? What is unclear?

Sign in to reply to this post
Did this help? Tips are appreciated...
loading

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...