close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Adding file name to database

Thread began 11/22/2009 11:20 pm by arista341524 | Last modified 11/23/2009 10:59 am by arista341524 | 1307 views | 1 replies

arista341524

Adding file name to database

Hello - Thanks in advance for any help you can offer.

I'm so close to being done with this website, but I can't figure out how to finish this final part. I've had to make some pretty major modifications to the code, and now I can't see the 'Insert Record' option in the Server Behaviors panel when I've got my product_Insert.php page open in Dreamweaver.

I'm having trouble getting the image file names added to the database. THe images themselves are uploading just fine to my server, but the db isn't getting any info.

Here's my code... can anyone help me make the necessary modifications?

Thanks,
Arista

<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult5");
if(isset($_POST["Insert_x"])){
WA_DFP_UploadFile("WA_UploadResult5", "img1", "", "images/products/", "".((isset($_FILES["img1"]))?$_FILES["img1"]["name"]:"") ."", "2", "[FileName]_[Increment]", "1000", "true", "0", "0");
}
?>

<?php
// WA Application Builder Insert
if (isset($_POST["Insert_x"])) // Trigger
{
$WA_connection = $connection;
$WA_table = "product";
$WA_sessionName = "WADA_Insert_product";
$WA_redirectURL = "product_Detail.php";
$WA_keepQueryString = false;
$WA_indexField = "inv_number";
$WA_fieldNamesStr = "prod_name|prod_descrip|price|img1|img2|img3|img4|material_cat|form_cat|avail";
$WA_fieldValuesStr = "".((isset($_POST["prod_name"]))?$_POST["prod_name"]:"") ."" . "|" . "".((isset($_POST["prod_descrip"]))?$_POST["prod_descrip"]:"") ."" . "|" . "".((isset($_POST["price"]))?$_POST["price"]:"") ."" . "|" . "".((isset($_POST["img1"]))?$_POST["img1"]:"") ."" . "|" . "".((isset($_POST["img2"]))?$_POST["img2"]:"") ."" . "|" . "".((isset($_POST["img3"]))?$_POST["img3"]:"") ."" . "|" . "".((isset($_POST["img4"]))?$_POST["img4"]:"") ."" . "|" . "".((isset($_POST["material_cat"]))?$_POST["material_cat"]:"") ."" . "|" . "".((isset($_POST["form_cat"]))?$_POST["form_cat"]:"") ."" . "|" . "".((isset($_POST["avail"]))?$_POST["avail"]:"") ."";
$WA_columnTypesStr = "',none,''|',none,''|none,none,NULL|',none,''|',none,''|',none,''|',none,''|',none,''|',none,''|none,none,NULL";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $dbname;
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);
}
}
?>

<?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;
}
}
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Insert product</title>

<link href="WA_DataAssist/styles/Traditional_Moab.css" rel="stylesheet" type="text/css" />
<link href="WA_DataAssist/styles/Arial.css" rel="stylesheet" type="text/css" />
</head>

<body>

<div class="WADAInsertContainer">
<form action="product_Insert.php" method="post" enctype="multipart/form-data" name="WADAInsertForm" id="WADAInsertForm">
<div class="WADAHeader">Insert Record</div>
<div class="WADAHorizLine"><img src="WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div>
<table class="WADADataTable" cellpadding="0" cellspacing="0" border="0">
<tr>
<th class="WADADataTableHeader">Inventory Number</th>
<td class="WADADataTableCell"></td>
</tr>
<tr>
<th class="WADADataTableHeader">Item Name</th>
<td class="WADADataTableCell"><input type="text" name="prod_name" id="prod_name" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">Item Description</th>
<td class="WADADataTableCell"><textarea name="prod_descrip" id="prod_descrip" cols="32"></textarea></td>
</tr>
<tr>
<th class="WADADataTableHeader">Price</th>
<td class="WADADataTableCell"><input type="text" name="price" id="price" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">Main Image</th>
<td class="WADADataTableCell">


<input type="file" name="img1" id="img1" />
</td>
</tr>
<tr>
<th class="WADADataTableHeader">Image 2</th>
<td class="WADADataTableCell"><input type="file" name="upload2" id="img2" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">Image 3</th>
<td class="WADADataTableCell"><input type="text" name="img3" id="img3" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">Image 4</th>
<td class="WADADataTableCell"><input type="text" name="img4" id="img4" value="" size="32" /></td>
</tr>
<tr>
<th class="WADADataTableHeader">Material Category</th>
<td class="WADADataTableCell"><input type="radio" name="material_cat" id="material_cat" value="ss" />
Sterling Silver<br />
<input type="radio" name="material_cat" id="material_cat" value="mm" />
Mixed Metal
<input type="radio" name="material_cat" id="material_cat" value="op" />
Opal</td>
</tr>
<tr>
<th class="WADADataTableHeader">Form Category</th>
<td class="WADADataTableCell"><input type="radio" name="form_cat" id="form_cat" value="br" />
Bracelets<br />
<input type="radio" name="form_cat" id="form_cat" value="nk" />
Necklaces & Pendants
<input type="radio" name="form_cat" id="form_cat" value="ot" />
Earrings & Other</td>
</tr>
<tr>
<th class="WADADataTableHeader">Qty Available</th>
<td class="WADADataTableCell"><input type="text" name="avail" id="avail" value="" size="2" /></td>
</tr>
</table>
<div class="WADAHorizLine"><img src="WA_DataAssist/images/_tx_.gif" alt="" height="1" width="1" border="0" /></div>
<div class="WADAButtonRow">
<table class="WADADataNavButtons" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="WADADataNavButtonCell" nowrap="nowrap"><input type="image" name="Insert" id="Insert" value="Insert" alt="Insert" src="WA_DataAssist/images/Moab/Traditional_insert.gif" /></td>
<td class="WADADataNavButtonCell" nowrap="nowrap"><a href="product_Results.php" title="Cancel"><img border="0" name="Cancel" id="Cancel" alt="Cancel" src="WA_DataAssist/images/Moab/Traditional_cancel.gif" /></a></td>
</tr>
</table>
<input name="WADAInsertRecordID" type="hidden" id="WADAInsertRecordID" value="" />
</div>
</form>

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